MY command is very basic and i want to get the last access information on the server through last write time as get-lastlogon on the server is not helping me to get the correct last access on the sever.
#############################################################################################
$listofdeviceids = get-WmiObject win32_logicaldisk | Select DeviceID,DriveType | where {$.DriveType -notlike “5”}
foreach ($DeviceId in $listofdeviceids)
{
Get-ChildItem -Recurse $DeviceId | ?{ $.PSIscontainer} | select FullName,LastWriteTime | sort Lastwritetime,FullName | ft lastwritetime,FullName | out-file -filepath “C:\Test\Output\lastaccessfiledetails.txt” -Append
}
###################################################################################################
I am receiving below error post executing the above command .
#######################################################################################################
Get-ChildItem -Recurse $DeviceId | ?{ $_.PSIscontainer} | select FullName,LastW …
-
+ CategoryInfo : ObjectNotFound: (@{DeviceID=Q:String) [Get-ChildItem], DriveNotFoundException + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem : Cannot find drive. A drive with the name ‘@{DeviceID=V’ does not exist.
At line:4 char:2
- Get-ChildItem -Recurse $DeviceId | ?{ $_.PSIscontainer} | select FullName,LastW …
-
+ CategoryInfo : ObjectNotFound: (@{DeviceID=V:String) [Get-ChildItem], DriveNotFoundException + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem : Cannot find drive. A drive with the name ‘@{DeviceID=Z’ does not exist.
At line:4 char:2
- Get-ChildItem -Recurse $DeviceId | ?{ $_.PSIscontainer} | select FullName,LastW …
-
+ CategoryInfo : ObjectNotFound: (@{DeviceID=Z:String) [Get-ChildItem], DriveNotFoundException + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
####################################################################################################################
Please suggest … where i am doing wrong