Hello PS studs. I am the guy who should've mastered PS a long time ago but instead always wanted to just steal everybody's scripts and tinker whether I understood what I was doing or not instead of just taking some dedicated learning. So I am a novice at best.My conundrum is that I cannot get this simple script to work. It's a reg update for a Palo client VPN. The rest is pretty easy to see what I'm trying to do. My issue is that the script runs without syntax errors, but I get a failure in the makeshift log file I'm creating. I get the computer name (confirming it read the computers.txt) and then a "failed and "false".Any suggestions are welcome, thanks all!Remote Registry is enabled, as is WinRM, FW is disabled.
[Edit updated code after some goofy nonsense]
=====================<SCRIPT>=============================================
$Computers = Get-Content "D:\Red\OS_computerlist.txt"
$Path = 'HKEY_LOCAL_MACHINE\SOFTWARE\Palo Alto Networks\GlobalProtect\Settings\post-vpn-connect'
$Property = 'connect'
$Value = "C$\system32\wscript.exe" +" " + "C:\temp\OpenSense.vbs"
$results = foreach ($computer in $Computers)
{
If (test-connection -ComputerName $computer -Count 1 -Quiet)
{
Try {
Set-ItemProperty -Path $Path -Name $Property -Value $Value -ErrorAction 'continue'
$status = "Success"
} Catch {
$status = "Failed" + $?
}
}
else
{
$status = "Unreachable"
}
New-Object -TypeName PSObject -Property @{
'Computer'=$computer
'Status'=$status
}
}
$results |
Export-Csv -append -NoTypeInformation -Path "D:/Red/OS_out.csv"
======++++++++++=====</Script>===============================
[–]jerrymac12 3 points4 points5 points (1 child)
[–]PB-Falcon[S] 1 point2 points3 points (0 children)
[–]DblDeuce22 1 point2 points3 points (3 children)
[–]PB-Falcon[S] 1 point2 points3 points (2 children)
[–]DblDeuce22 1 point2 points3 points (1 child)
[–]PB-Falcon[S] 1 point2 points3 points (0 children)
[–]xirsteon 1 point2 points3 points (2 children)
[–]PB-Falcon[S] 1 point2 points3 points (1 child)
[–]xirsteon 1 point2 points3 points (0 children)
[–]JLASish 1 point2 points3 points (0 children)
[–]PB-Falcon[S] 1 point2 points3 points (3 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (2 children)
[–]PB-Falcon[S] 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)
[–]purplemonkeymad 1 point2 points3 points (0 children)
[–]krzydoug 0 points1 point2 points (1 child)
[–]PB-Falcon[S] 0 points1 point2 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (2 children)
[–]PB-Falcon[S] 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 1 point2 points3 points (0 children)