I needed to check for an installed program on a number of remote servers without having to log in to each one individually. Unfortunately, whilst the program is listed in Control Panel > Add / Remove Programs, it does not get returned via Powershell when running;
Get-WMIObject Win32_Product
Running the following script allowed me to import a list of servers then search for a file or folder on those servers. Following the search the server name and result of the search is outputted to the screen;
#Import list of servers
$cns = Get-Content "C:\Users\LangridgeJ\Desktop\list-of-servers.txt"
#Scan for selected file or folder
foreach ($cn in $cns)
{$path = Test-Path "\\$cn\C$\Path\To\Folder\Or\File"
#Write output to screen
If ($path -eq $true ) { Write-Host $cn 'Files or folders are present' }
Else { Write-Host $cn 'No files or folders are present' } }
That is really interesting, You are an overly professional blogger. I have joined your RSS feed and look ahead to in the hunt for more of your great post. Additionally, I have shared your web site in my social network's description: The Ninja Guide To How To Lock Files Better.
ReplyDelete