Powershell – Copy files from UNC and elevate to get rights

Install.ps1

$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = new-object Security.Principal.WindowsPrincipal $identity
if ($principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) -eq $false)
{ $psArgs = ’-noprofile -nologo -executionpolicy bypass -file ”{0}”’ -f $MyInvocation.MyCommand.Path
Start-Process -FilePath ’powershell.exe’ -ArgumentList $psArgs -Verb RunAs
exit }

$Source = split-path -parent $MyInvocation.MyCommand.Definition
$dest=”C:\AXIS Camera Control”
if (!(Test-Path -path $dest)) {New-Item $dest -Type Directory} # Skapa katalogen om den saknas !
Copy-Item $Source\filer\* $Dest -recurse #Kopiera filerna…
Start-Process -FilePath ($dest + ”\AXISCameraControlSDK.exe”) #Starta SDK installationen
regsvr32 ($dest + ”\AxisCameraControl.ocx”)

Session controling…

@echo off
net pause Netlogon
net pause Server
net session /delete /y
echo.
echo Paused Server and all users are disconnected FORCED !
echo.
echo.
pause

@echo off

net continue Server
net continue Netlogon
echo Server now in execute mode !
pause

SUBs… grrr hard to remember :)

Net bits

Subnet mask

total-addresses per subnet

/20 255.255.240.0 4096
/21 255.255.248.0 2048
/22 255.255.252.0 1024
/23 255.255.254.0 512
/24 255.255.255.0 256
/25 255.255.255.128 128
/26 255.255.255.192 64
/27 255.255.255.224 32
/28 255.255.255.240 16
/29 255.255.255.248 8
/30 255.255.255.252 4