Write Out to Console the Remaining Space for a Particular Drive

$driveLetter = Read-Host “Enter drive letter”
$DiskDrive = Get-WMIObject Win32_LogicalDisk | Where {$_.DeviceId -Eq $driveLetter + “:”}
$DriveSpace = ($DiskDrive.FreeSpace /1GB)

Write-Host Available Free Disk Space = $DriveSpace GB

Posted in Uncategorized | Leave a comment

A Function to Write Out Details About a Computer’s Network Adapters

Function NetworkInfo {

$colItems = Get-WmiObject Win32_NetworkAdapterConfiguration -Namespace “root\CIMV2″`
-ComputerName $strComputer | where{$_.IPEnabled -eq “True”}

foreach($objItem in $colItems) {
Write-Host “DHCP Enabled:” $objItem.DHCPEnabled
Write-Host “IP Address:” $objItem.IPAddress
Write-Host “Subnet Mask:” $objItem.IPSubnet
Write-Host “Gateway:” $objItem.DefaultIPGateway
Write-Host “MAC Address:” $ojbItem.MACAddress
}

}

Posted in Uncategorized | Leave a comment

Count the Number of Services

Get-service | foreach {$t=0} {$t +=1} {“Total services: $t”}

Posted in Uncategorized | Leave a comment

Display OS Services (with Display Name Column Heading Formatted)

Get-Service * | Sort-Object -property ServiceType, DisplayName | format-Table name, @{Label=”Display Name”; Expression=”Name”}, ServiceType, status, CanStop, -auto

Posted in Uncategorized | Leave a comment

Search Recursively for All png or gif Files using Regex

Get-ChildItem . -recurse | ?{$_.name -match “^*.png|gif$”} | Sort-Object name | ft directory, name

Posted in Uncategorized | Leave a comment

Find Files With the Word “Linq” in the Name Recursively – Order Descending by Name

Get-ChildItem . -filter *Linq* -recurse | Sort-Object name -desc | ft directory, name

Posted in Uncategorized | Leave a comment

List Databases on Server “Walker”

Clear-Host

Add-PSSnapin SqlServerCmdletSnapin100
Add-PSSnapin SqlServerProviderSnapin100

Set-Location SQLSERVER:\SQL\WALKER\Default\DataBases

Get-ChildItem | Select-Object PSChildName

Remove-PSSnapin SqlServerCmdletSnapin100
Remove-PSSnapin SqlServerProviderSnapin100

Posted in Uncategorized | Leave a comment