

#Write-ErrorLog -hostname "Get-ComputerInfo was failing." -errormsg $errormsg -exception $exception -scriptname "GetComputerInfo.ps1" Write-ErrorLog -hostname "Get-ComputerInfo CmdLet was failing." -env "ALL" -logicalname "ALL" -errormsg $errormsg -exception $exception -scriptname $scriptname -failinglinenumber $failinglinenumber -failingline $failingline -pscommandpath $pscommandpath -positionmsg $pscommandpath -stacktrace $stacktrace Write-Verbose "Start writing to Error log." $pscommandpath = $_.InvocationInfo.PSCommandPath $positionmsg = $_.InvocationInfo.PositionMessage $failingline = "Test-Path -Path $importfile -PathType Leaf" $exception = "Read Get-ComputerInfo CmdLet help to find out more info." $errormsg = "List of server names file $importfile does not exist." Write-Warning "Read Get-ComputerInfo CmdLet help to find out more info." Write-Warning "List of server names file $importfile does not exist." Write-Warning "Get-ComputerInfo CmdLet failed." That will create the list of servers ( $computers) that we want to process with our Get-CPUInfo CmdLet BEGIN | Select-Object -Property hostname, ipaddress, logicalname, environment Step 1 – Read the text file in Get-CPUInfo CmdLet using Get-Content CmdLet.
#Powershell import csv code#
Here are the code snippets of the implementation: The content of text files is very similar to the content of the example from the beginning of this article.ĬPU properties for a list of servers using Get-CPUInfo CmdLet

OKFINservers.csv file content example Text Files
