Saturday, June 28, 2008
Previous Post mentioned in PowerScripting Podcast - Episode 30
Thursday, June 26, 2008
ASPNet_WP.exe analysis on multiple servers via PowerGadgets
Steps are:
- Get WorkingSizeSet of the ASPNet_WP on the servers via WMI
###################################################
# Script Name: Get-ASPNet_WP.ps1
# Description: PowerShell Script for ASPNet_WP
# analysis on intapp-p2, webster-vp01
# and webster-vp02
#
# Created By: Wes Stahler
# Date Created: 6/25/2008
# Change Log:
# 6/26/2008 Added PowerGadget chart for
# inclusion on admin web page
###################################################
# Get password from encrypted file
# Once these servers are moved into the correct domain
# we won't have to worry about the creds....
$password = Get-Content c:\cred.txt ConvertTo-SecureString
# Create credentials
$creds = New-Object -typename System.Management.Automation.PSCredential `
-argumentlist "nt3osumc\stah06",$password
# Get WorkingSetSize for the 3 NT3OSUMC servers
$intapp_p2 = Get-WmiObject -Class Win32_Process `
-ComputerName intapp-p2 -Credential $creds `
Where-Object {$_.ProcessName -eq "aspnet_wp.exe"} `
Sort-Object WorkingSetSize -Descending `
Select-Object -First 1
$webster_vp01= Get-WmiObject -Class Win32_Process `
-ComputerName webster-vp01 -Credential $creds `
Where-Object {$_.ProcessName -eq "aspnet_wp.exe"} `
Sort-Object WorkingSetSize -Descending `
Select-Object -First 1
$webster_vp02= Get-WmiObject -Class Win32_Process `
-ComputerName webster-vp02 -Credential $creds `
Where-Object {$_.ProcessName -eq "aspnet_wp.exe"} `
Sort-Object WorkingSetSize -Descending `
Select-Object -First 1
# Being lazy....
$intappp2 = [math]::Round($intapp_p2.workingsetsize/1024/1024,0)
$webstervp01 = [math]::Round($webster_vp01.workingsetsize/1024/1024,0)
$webstervp02 = [math]::Round($webster_vp02.workingsetsize/1024/1024,0)
$dt = Get-Date -Format T
# Format string for to append to the historical file
# Will add to a DB later
$str = "{0},{1},{2},{3}" -f $dt,$intappp2,$webstervp01,$webstervp02
# Append to file
Add-Content -Path "c:\ProductionScripts\ASPNet_WP.csv" -Value $str
# Grab the data (last 7 hours worth) and chart!
$b = Import-Csv "c:\ProductionScripts\ASPNet_WP.csv" select -last 28
$b Out-Chart -Values Intapp-p2, webster-vp01, Webster-vp02 `
-Label Time `
-Title "ASPNet_WP.exe as of $dt" `
-gallery Lines `
-AxisY_Max 1000 `
-Size 800,533 `
-Series_1_AxisY AxesY_0 `
-Series_2_AxisY AxesY_0 `
-Output "file://intapp-p2/e$/Inetpub/Extranet/ProjectManager/Exception/ASPNet_WP.png"
###################################################
Tuesday, June 24, 2008
Awesome post - Powershell Tip - Storing and Using Password Credentials
This is very handy when you are dealing with multiple domains.
Monday, June 23, 2008
Following is a script used to gather this information.
Now if I could only find a way to get the file count.....
function Get-DriveInventory
{
PROCESS
{
#get drives from WMI
$drives = gwmi win32_logicaldisk -comp $_ -filter "drivetype=3"
#construct output objects
foreach ($drive in $drives)
{
$obj = New-Object psobject
$obj Add-Member NoteProperty ComputerName $_
$obj Add-Member NoteProperty DriveLetter $drive.deviceid
$obj Add-Member NoteProperty VolumeName $drive.VolumeName
$free = $drive.freespace/1MB -as [int]
$obj Add-Member NoteProperty AvailableSpace $free
$total = $drive.size/1MB -as [int]
$obj Add-Member NoteProperty TotalSpace $total
Write-Output $obj
}
}
}
function Get-FileName
{
$computer = Read-Host "Filename of computer names?"
return $computer
}
# get the filename
$f = Get-FileName
Get-Content $f Get-DriveInventory Export-Csv "C:\Users\Public\Documents\DriveInventory.csv"
Friday, June 20, 2008
Vista SP1 and PowerShell Commands for Active Directory by Quest Software
Wednesday, June 18, 2008
Change DNS/WINS IP on Multiple Servers
function Set-DNSWINS {
#Get NICS via WMI
$NICs = Get-WmiObject '
-Class Win32_NetworkAdapterConfiguration '
-ComputerName $_ '
-Filter "IPEnabled=TRUE"
foreach($NIC in $NICs) {
$DNSServers = "12.34.5.67","76.54.3.21"
$NIC.SetDNSServerSearchOrder($DNSServers)
$NIC.SetDynamicDNSRegistration("TRUE")
$NIC.SetWINSServer("12.345.67.890", "12.345.67.891")
}
}
function Get-FileName {
$computer = Read-Host "Filename of computer names?"
return $computer
}
$f = Get-FileName
Get-Content $f foreach {Set-DNSWINS}
Gotta love PowerShell!
TechEd 2008
Lots of swag was distributed, including PowerGadgets, you gotta take a look at this cool product!