get-childitem is going after other directories
Posted: Fri Jan 22, 2016 5:15 pm
I have a script that goes out and deletes folders left over from installations
INVOKE-COMMAND -COMPUTERNAME $computer -SCRIPTBLOCK { GET-CHILDITEM -PATH C:\SWSetup -recurse | WHERE-OBJECT { $_.PSISCONTAINER -AND (GET-CHILDITEM -PATH $_.FULLNAME -recurse | WHERE-OBJECT { !$_.PSISCONTAINER }) -EQ $NULL } | REMOVE-ITEM -FORCE -RECURSE }
But, a lot of the times it hangs and I just ran it through ISE and I'm getting this
The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
+ CategoryInfo : ReadError: (C:\Program File...sut\diagnostics:String) [Get-ChildItem], PathTooLongException
+ FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand
+ PSComputerName : computername
The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
+ CategoryInfo : ReadError: (C:\Program File...sut\diagnostics:String) [Get-ChildItem], PathTooLongException
+ FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand
+ PSComputerName : computername
The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
+ CategoryInfo : ReadError: (C:\Windows\CSC\...0145efa6b30.swf:String) [Get-ChildItem], PathTooLongException
+ FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand
+ PSComputerName : computername
The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
+ CategoryInfo : ReadError: (C:\Windows\CSC\...nd Calculations:String) [Get-ChildItem], PathTooLongException
+ FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand
+ PSComputerName : computername
Why is it searching other directories? Is this normal?
INVOKE-COMMAND -COMPUTERNAME $computer -SCRIPTBLOCK { GET-CHILDITEM -PATH C:\SWSetup -recurse | WHERE-OBJECT { $_.PSISCONTAINER -AND (GET-CHILDITEM -PATH $_.FULLNAME -recurse | WHERE-OBJECT { !$_.PSISCONTAINER }) -EQ $NULL } | REMOVE-ITEM -FORCE -RECURSE }
But, a lot of the times it hangs and I just ran it through ISE and I'm getting this
The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
+ CategoryInfo : ReadError: (C:\Program File...sut\diagnostics:String) [Get-ChildItem], PathTooLongException
+ FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand
+ PSComputerName : computername
The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
+ CategoryInfo : ReadError: (C:\Program File...sut\diagnostics:String) [Get-ChildItem], PathTooLongException
+ FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand
+ PSComputerName : computername
The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
+ CategoryInfo : ReadError: (C:\Windows\CSC\...0145efa6b30.swf:String) [Get-ChildItem], PathTooLongException
+ FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand
+ PSComputerName : computername
The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
+ CategoryInfo : ReadError: (C:\Windows\CSC\...nd Calculations:String) [Get-ChildItem], PathTooLongException
+ FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand
+ PSComputerName : computername
Why is it searching other directories? Is this normal?