I have the below code using Get-Winevent and running into the below error, Any idea what am I missing here?
ComputerName = $Server.Name
PasswordExpiration = [datetime]::FromFileTime($Server."ms-Mcs-AdmPwdExpirationTime")
line : 148 PasswordLastSet = (Get-WinEvent -ProviderName AdmPwd -ComputerName $Server.name | Where-Object {($.ID -eq 12)} | Sort-Object $.TimeCreated | Select-Object -Last1).TimeCreated
Error msg:
Get-WinEvent : The RPC server is unavailable
At \po\scripts\New-LSReport\New-LSReport.ps1:148 char:24
- ... dLastSet = (Get-WinEvent -ProviderName AdmPwd -ComputerName $Server.n ...
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : NotSpecified: (:) [Get-WinEvent], EventLogException
- FullyQualifiedErrorId : System.Diagnostics.Eventing.Reader.EventLogException,Microsoft.PowerShell.Commands.GetWi
nEventCommand