Link to home
Start Free TrialLog in
Avatar of xouvang
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.
ASKER CERTIFIED SOLUTION
Avatar of Raheman M. Abdul
Raheman M. Abdul
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of xouvang
xouvang

ASKER

Let's say computer is ANC54543 and the folder is TestUser


@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
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.
Avatar of xouvang

ASKER

ahhh ok got it

thanks!