Looking for Powershell script that allows me to delete profile path for every AD user in OU

Indie101
Indie101 used Ask the Experts™
on
Looking for a powershell script that will allow me delete the profile path in profile tab for every AD user in a particular OU

Is it a case of using

Set-ADUser -Clear ProfilePath within OU
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2018
Distinguished Expert 2018
Commented:
In test mode; remove the -WhatIf at the end to run it for real:
Get-ADUser -Filter "profilePath -like '*'" -SearchBase "OU=SomeUserOU,OU=SomeParentOU,DC=SomeDomain,DC=tld" | Set-ADUser -Clear profilePath -WhatIf

Open in new window

Author

Commented:
Thanks i get what if: Performing the operation "set" on target

If i add cn=testuser at start that will just take profile off that one yeah?
Most Valuable Expert 2018
Distinguished Expert 2018

Commented:
i get what if: Performing the operation "set" on target
That's the test mode as indicated above.
For testing with a single account, you can adjust the filter to use SamAccountName, or just go for the user's Identity
Still in test mode, will not change anything in AD until the -WhatIf is removed:
Get-ADUser -Identity testuser | Set-ADUser -Clear profilePath -WhatIf 

Open in new window

Author

Commented:
Super thanks very much :)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial