Check if PowerShell remote control is allowed
I have searched and cannot find exactly what I am looking for, I need to be able to test about 900 machines and tell if PowerShell toggle is enabled, I realized that with the script below I can check if PowerShell is installed but it does not check , can he remotely control the car, any ideas?
function Check-PSVersion
{
[CmdletBinding()]
Param (
[Parameter(Mandatory = $true)]
$ComputerName
)
if (Test-Path $ComputerName)
{
$Computers = Get-Content $ComputerName
}
Else
{
$Computers = $ComputerName
}
Foreach ($Computer in $Computers)
{
Try
{
Write-Host "Checking Computer $Computer"
$path = "\\$Computer\C$\windows\System32\WindowsPowerShell\v1.0\powershell.exe"
if (test-path $path) { (ls $path).VersionInfo }
else
{
Write-Host "Powershell isn't installed" -ForegroundColor 'Red'
}
Write-Host "Finished Checking Computer $Computer"
}
catch { }
}
}
+3
source to share
2 answers
risking being off topic ...
function server_available?( $_server_to_act_on ) {
if ( Test-Connection -ComputerName $_server_to_act_on -Count 1 -Quiet ) {
Write-Host "`nTest-Connection: $_server_to_act_on OK" -NoNewline
if ( [bool](Test-WSMan -ComputerName $_server_to_act_on -ErrorAction SilentlyContinue) ) {
Write-Host ", Test-WSMan: $_server_to_act_on OK" -NoNewline
if ( [bool](Invoke-Command -ComputerName $_server_to_act_on -ScriptBlock {"hello from $env:COMPUTERNAME"} -ErrorAction SilentlyContinue) ) {
Write-Host ", Invoke-Command: $_server_to_act_on OK" -NoNewline
return $true
}
}
}
return $false
}
0
source to share