40 lines
1.3 KiB
PowerShell
40 lines
1.3 KiB
PowerShell
Function Get-Bypass($ComputerName){
|
|
|
|
$BypassPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SMS\Client\Client Components\Remote Control"
|
|
$CommandStatus = $false
|
|
|
|
if(!(Test-Connection -ComputerName $ComputerName -Count 1))
|
|
{
|
|
Write-Host "Exiting bypass...No connection made to [$ComputerName]" -ForegroundColor Red
|
|
break
|
|
}
|
|
else
|
|
{
|
|
$CommandStatus = Invoke-Command -ComputerName $ComputerName -SessionOption (New-PSSessionOption -NoMachineProfile) -ScriptBlock {
|
|
|
|
if(Test-Path $Using:BypassPath)
|
|
{
|
|
Set-ItemProperty -Path $Using:BypassPath -Name "Permission Required" -Value 0
|
|
|
|
Return $true
|
|
}
|
|
else
|
|
{
|
|
Return $false
|
|
}
|
|
|
|
Return $false
|
|
}
|
|
|
|
if($CommandStatus)
|
|
{
|
|
Write-Host "Executed system bypass successfully on [$ComputerName] `nPath: $BypassPath" -ForegroundColor Green
|
|
}
|
|
else
|
|
{
|
|
Write-Host "Failed system bypass on [$ComputerName]`nPath: $BypassPath`nCheck [$ComputerName] is running Powershell V3.0 or above.`nCheck that registry exists." -ForegroundColor Red
|
|
}
|
|
}
|
|
|
|
Remove-PSSession $ComputerName
|
|
} |