function Set-Title { Param ([string]$NewTitle) $host.ui.rawui.WindowTitle=$NewTitle } Set-Alias title Set-Title function Save-Title { $script:SavedTitle=$host.ui.rawui.WindowTitle } #call the Save-Title function Save-Title $report="report.txt" #write a line to the report "REPORT CREATED $(get-date)" | Out-File $report Get-Content servers.txt | foreach { #skip blank lines if (($_).length -gt 0) { #create a new variable to make things easier to read and #trim off any extra spaces. Make the name upper case #while we're at it. $server=($_.Trim()).ToUpper() $newtitle="Checking $server" #set a new title title $newtitle $server | Out-File $report -append "Operating System" | Out-File $report -append Get-WmiObject win32_operatingsystem -computer $server | Out-File $report -append "ComputerSystem" | Out-File $report -append Get-WmiObject win32_computersystem -computer $server | Out-File $report -append #pause for a few seconds just to show title in action #not really required. sleep 2 } #end If } #end foreach #revert back to old title Title $script:savedtitle #view report Notepad $report