Posts

Showing posts from August, 2014

Powershell - get all host files on domain.

Purpose: This script will search AD for Window computers and attempted to connect to each one. Then it will read the contents of the host file and write them to a csv file.

Note: This will take a while to run unless someone wants to make it multithreaded.
I just wrote this so there may need to be some bug fixes but in general it seemed to work.

#Read all host files and write to CSV file Import-Module ActiveDirectory $PATH = "c:\temp\hostfiles.csv" $myCol = @() $AllComputers = Get-ADComputer -Filter {OperatingSystem -Like "Windows*"} -Property * | Select -Expand Name foreach ($Computer in $AllComputers){ $i++ Write-Progress -activity "Scanning Machine $Computer " -status "Scanned: $i of $($AllComputers.Count)" -percentComplete (($i / $AllComputers.Count) * 100) Get-Content -Path "\\$Computer\c$\windows\system32\drivers\etc\hosts" | where {!$_.StartsWith("#")} | foreach { …

Powershell: Get list of all services accounts used on Windows servers in domain.

Purpose: This script will search AD for Windows Servers that are enabled and attempted to connect to each server and get a listing of all services and the accounts used to run them.
Note: This will take a while to run unless someone wants to make it multithreaded.
I just wrote this so there may need to be some bug fixes but in general it seemed to work.
Requirements: RSAT tools WMI


Import-Module activedirectory cls $ServicesReport = @() $AllServers = Get-ADComputer -Filter {(OperatingSystem -Like "Windows Server*")-and (enabled -eq "true")} -Property SamAccountName | select -expand Name $i = 0 foreach($Server in $AllServers) { $i++ Write-Host "Working on Server: $Server " $i " of " $AllServers.Count try { if (Test-Connection -ComputerName $Server -Quiet) { $Services = Get-WmiObject win32_service -ComputerName $Server | select Name, @{N="StartupType";E={$_.StartMode}}, @{N="ServiceAccount";E={$_.StartName}}, …

Powershell-DellBatchWarrentylookup

Purpose: This script will read serial numbers from a text file then search dells site for warranty information. The get-dellassetinfo function i found from some forum but don't remember where.


################################### $ComputerSerials = gc "c:\temp\SerialNumbers.txt" ################################### Function Get-DellAssetInfo([string]$ServiceTag){ $Asset=New-WebServiceProxy -Uri 'http://xserv.dell.com/services/AssetService.asmx?WSDL' -UseDefaultCredential $Asset.GetAssetInformation([Guid]::NewGuid(),'AssetService',$ServiceTag); } $myCol = @() foreach ($ComputerSerial in $ComputerSerials) { $results=Get-DellAssetInfo $ComputerSerial $SystemType = $results.AssetHeaderData.SystemType $ServiceLevelDescription = $results.Entitlements.ServiceLevelDescription $SystemModel = $results.AssetHeaderData.SystemModel $Region = $results.AssetHeaderData.Region $StartDate = $results.Entitlements.StartDate.Date | Select -ExpandProperty …