file exists

October 25, 2008 by admin  
Filed under Powershell

This will display if a file exists using Powershell

$file = Dir $env:windir\explorer.exe
$file.Exists

Which will display true if explorer exists

Display network information using Powershell

August 13, 2008 by admin  
Filed under Powershell

 This example will display various snippets of network related information using Powershell

Cls
$strComputer = “.”
$colItems = get-wmiobject -class “Win32_NetworkAdapterConfiguration” `
-computername $strComputer | Where{$_.IpEnabled -Match “True”}
foreach ($objItem in $colItems)
{
write-host “MAC Address : ” $objItem.MACAddress
write-host “IPAddress : ” $objItem.IPAddress
write-host “DNS Servers : ” $objItem.DNSServerSearchOrder
Write-host “”
}