Powershell copy files and overwrite4/6/2024 The Exclude parameter is effective only when the command includes the contents of If you really want to pursue PowerShell, use Get-ChildItem to get your list of folders, pipe through Where-Object to exclude your specific folders, and then use Copy-Item. You need at least PowerShell 3.0 for this to work.Ĭopy-Item, For instance, it can copy files and directories in a file system drive and registry keys and This cmdlet can copy and rename items in the same command. Get-ChildItem "c:\temp\test" -Directory |Ĭopy-Item -Destination $dirName -Recurse -Force Filter out the exclusions using -notin and pass the rest to Copy-Item $excludes = "custerr","history","logs","temp","wwwroot" Then use Get-ChildItem to get all the folders in the inetpub directory. Since you are accessing them via UNC paths we cannot really use the c:\ path (We can get around this but what I am about to show should be good enough.). Build an array of the parent folders that you want to exclude. This is a simple example of something you could do.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |