Hi
I am looking for some help with a PowerShell script.
I am trying to search through folders using the get-child item. I have created an array($strFolderNames) which contains reference numbers which are in included in the folders I am trying to find. I want to be able to find the folders I am looking for in a directory, select them and then move them to a different server while maintaining their existing folder structure. I am running into problems when I am trying to use my array with -like parameter
This is what I have so far. I think what I am missing is a for/foreach loop but I can't for the life of me figure it out.
Here is what I have so far.
PS C:\Windows> $strFolderNeeded = Get-Content 'C:\Folders to ArchiveWC.csv'
PS C:\Windows> cd \\<remote server>\folder
PS Microsoft.PowerShell.Core\FileSystem::\\<remote server>\folder
> Get-ChildItem | Where-Object {$_.name -like $strFolderNeeded}
The command executes fine but returns zero results however if I change the last command slightly to
PS Microsoft.PowerShell.Core\FileSystem::\\<remote server>\folder
> Get-ChildItem | Where-Object {$_.name -like $strFolderNeeded[0]}
It returns with the folder I am looking for that is positioned 1st in the variable
What I want it to do is go through the array and return only the folders I am looking for that contain the reference numbers held in the variable "$strFoldersNeeded".
Thanks
Sokaar