Hi Team,
I am trying to print the error by using $Error variable, I am able to print the error, but want to know from which server, the following error is coming.
I am using following code;
Invoke-Command -ComputerName $vm -ScriptBlock {get-childitem -Path C:\inetpub\logs\LogFiles\ -recurse $vm | where-object {$.lastwritetime -lt (get-date).addDays(-300)} | Foreach-Object { del $.FullName } }
Kindly help me to get the error message along with the server name.