About us

IIS covers the IT solutions to the issues come across now and then in a company IT infrastructure including Operating system, Softwares, Scriptings, securities and reviews.

Thursday, 6 March 2014

PowerShell Scripts - File exist or not

In an organisation where software inventory application does not exist Scripts plays a good role. I met one situation where we had to analyse that in how many computers of our organisation has Winzip installed so that licenses can be procured before they raid us and charge the fine upon.Thus inspired me to create a script which would explore the files remotely exist or not.

I have again used the powershell to make this happen. Script would go through the text file which has computer names in it and will execute the same command one by one on all of them.


$colComputers = Get-Content C:\FileName.txt
$ErrorActionPreference = "SilentlyContinue"
foreach ($StrComputer in $colComputers)
{
$GenItems1 = gwmi Win32_ComputerSystem -Comp $StrComputer
$x86Path = 'C:\Program Files (x86)\WinZip\WZCAB.DLL'
if(!$GenItems1){
Write-Host “$StrComputer not found”
}
else
{
Write-Host $StrComputer, (Get-Item $x86Path | Select -ExpandProperty VersionInfo).fileVersion
}
}



Regards,
Baij

No comments:

Post a Comment