Aman Kr
Aman Kr

Reputation: 11

Powershell script tool to rename profile folders in networks share

I am new to Powershell scripting and needs some guidance on creating a script.

We've have terminal server environment where we have to regularly reset user profile in order to resolve application related issues for them. Currently we rename the user profile folder manually to .old, which forces the profile service create a new profile for user next time they login. We are thinking to create a powershell based tool to do this operation for some priority users not from technical domain.

Currently we have one user, who has different profile in different file share depending on which region (Asia, America) user is connecting to. I am looking to create a script which first loads the folders from all region file shares(for performance reason), then a list box to select the region Asia or America, and a username search box. The script should search for the username profile folder in the selected region only.

I havefound only a small bit, need help constructing rest

# Date to append folder name
$Date = Get-Date -Format yyyyMMddhhmm

# List of file shares for FsLogix containers
$FileShares = "\\abc\fileshare"

# Retrieving list of subfolders in each file share
$Containers = foreach ($FileShare in $FileShares) {((Get-ChildItem -Path $FileShare -Directory -Force).FullName)} 

# Display containers to select for rename/removal
$UserContainer = $Containers | Out-GridView -PassThru

# Rename container to _OLD with date
Rename-Item $UserContainer -NewName $UserContainer"_OLD_"$Date 

Upvotes: 1

Views: 752

Answers (0)

Related Questions