New to PowerShell script so thought to ask for directions here. Learn as I go so forgive my noob sense.
I wrote a script that does exactly what I needed it done. Nothing fancy… just getting the job done. here goes the description…
The script calls a list of workstations. It performs a test-connection and then output the result into two files 1) AbleToConnect.txt and 2) UnableToConnect.txt. Then the second part of the script is calling the AbleToConnect.txt and checking to see if each machine has Office 365 ProPlus installed or not. If installed, it export the confirmation to a CSV file I named ConfirmedOPPInstalled.csv. I got everything to work except for where if it can’t find MS Office 365 ProPlus on the machine it then export the list of the workstations from the AbleToConnect.txt to a text file called NoOPPInstalled.txt.
Below is the 2nd part of the script.
foreach ($workstation in (Get-Content “.\result\AbleToConnect.txt”))
{
write-verbose “Working on $workstation…” -Verbose
Invoke-Command “$workstation” -ScriptBlock {
Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\O365ProPlus* | Select-Object DisplayName, DisplayVersion, Publisher
} | export-csv “.\result\ConfirmedOPPInstalled.csv” -NoTypeInformation -Append -Force
Thanks in advance.