Hello again,
I need some help changing the output of a column in my script.
I've a script that gets last update time by reading a registry key. The value returned is in form of "yyyy/mm/dd hh:mm:ss", I need to split it into 2 columns. If not possible, just remove the hour would be enough.
## Library script # . "C:\library.ps1" # ##BEGIN # # #Set list path $file= "C:\wklist.txt" # # cls Write-Host "Aguarde..." # #Get credential $cre1 = Get-Credential "Enter Credential" #Loads list content Get-Content $file | ForEach-Object { #ICMP test 4 packets If(Test-Connection -ComputerName $_ -count 4 -Quiet ){ Invoke-Command -cn $_ -ScriptBlock { Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\Results\Install" -ErrorAction SilentlyContinue } -Credential $cre1 } #If ICMP fails Else{New-Object PSObject -Property @{PSComputerName="$_";LastSuccessTime="OFFLINE"} } } | Select PSComputerName,LastSuccessTime | Sort PSComputerName,LastSuccessTime | Export-Csv "c:\temp\lastupdate_result.csv" -NoTypeInformation # Pause # # ##END
In Test-Connection I need the 4 samples because I will collect data on a very big network.
- Edited by H Souza 1 hour 42 minutes ago