xouvang
asked on
Powershell script to add .old to folders?
Hi all,
I need a script that adds .old to a folder. I already got the script to remove any folder with .old in them.
I have users that get corrupted profiles. Instead of trying to remote into their computer and rename their profiles to .old, is there a script to add .old their profile folder?
What I want to do is launch the script change the name and the computer. Once I make that change I run the script and it will automatically add .old to their profile.
So far I have get-childitem \\computer\c$\users - filter "profile folder name" | {where{$_.PsIsContainer} | rename-item
That's as far as I got, please let me know if I'm using the wrong script.
I need a script that adds .old to a folder. I already got the script to remove any folder with .old in them.
I have users that get corrupted profiles. Instead of trying to remote into their computer and rename their profiles to .old, is there a script to add .old their profile folder?
What I want to do is launch the script change the name and the computer. Once I make that change I run the script and it will automatically add .old to their profile.
So far I have get-childitem \\computer\c$\users - filter "profile folder name" | {where{$_.PsIsContainer} | rename-item
That's as far as I got, please let me know if I'm using the wrong script.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You are pasting the script into the powershell console. You need to save it as a .ps1. Fur example script.ps1.
You execute it from the console as follows:
C:\temp\script.ps1 -identity TestUser -conputername ANC54543
Replace c:\temp with the path to the script.
You execute it from the console as follows:
C:\temp\script.ps1 -identity TestUser -conputername ANC54543
Replace c:\temp with the path to the script.
ASKER
ahhh ok got it
thanks!
thanks!
ASKER
@LearnCTX - Ok I tried to run the codes and are getting errors. Attached is the screenshot below
@Raheman Mohammed Abdul - Thanks! Your code works
Thanks!
Capture.JPG