This function Is a Function on demand
And will be todays function gift to you all!
I wrote this right now for a friend of mine,
Stefan Schörling. He needed a script that will move
old users folders to another folder based on a text file.
This is a function that I wrote in 5 min, so It’s only the first version.
function Move-UserFolders { param ($userFile, $userFoldersPath, $userOld) $users = Get-Content $userFile foreach ($userFolder in $users) { $userFullPath = $userFoldersPath + $userFolder Move-Item $userFullPath $userOld -ErrorAction SilentlyContinue } }
You need to do 2 things before running this.
First of all do a text file with the users folder you want to move.
userfolders.txt
frwa8233
tret4322
trwe4468
And then make a folder where you want to archive this user folders.
In my case It will be in c:\scripts\old.
When that is done, we just need to call the function with
first the text file path and second with the path to the folder where all of the user folders are
and third we need the path to the archive folder.
Move-UserFolders 'c:\scripts\userfolders.txt' 'c:\katalog01\' 'c:\scripts\old'
No related posts.
Pingback: Fredrik Wall
RT @walle75: The function are updated with source folder, http://bit.ly/7cJZrO <=good update
Function of the day, Move-UserFolders, #PowerShell #Functions http://bit.ly/7cJZrO
RT @walle75: Function of the day, Move-UserFolders, #PowerShell #Functions http://bit.ly/7cJZrO <=cool
The function are updated with source folder, http://bit.ly/7cJZrO