Get-Content and Move-Item

Hopefully I explain this clearly.

We have 6 profile servers. I run a script that writes to a text file, the names of all dormant / inactive profiles.

What I want to do is read that text file and based on the names, move the folders / profiles to a folder named delete. This is quite easy to do, except the delete folder is not a central folder, it’s a separate folder within each profile server share.

Example:

\profile1\path$

\profile1\path$\delete

How would I be able to have the folders moved to the appropriate folder / share? From there I would do a mass deletion.

What do you have so far? With Move-Item or with robocopy you should be able to move anything easily as needed? But if you want to delete the folder anyway, why moving them arount before?
BTW: robocopy is even able to delete files and folders by mirroring an empty folder into the target folder. This way you wouldn’t have to touch files and folders twice. :wink:

  1. [quote quote=143274]What do you have so far? With Move-Item or with robocopy you should be able to move anything easily as needed? But if you want to delete the folder anyway, why moving them arount before?

    BTW: robocopy is even able to delete files and folders by mirroring an empty folder into the target folder. This way you wouldn’t have to touch files and folders twice. 😉

    [/quote]

I can have all the contents of the text file read and then the corresponding profiles moved to a central delete folder. That's fine.

What I’m struggling with: say I have a text file as so

\profile1\path$\bob.smith

\profile2\path$\jane.doe

I would want Bob to go to:

\profile1\path$\delete

And Jane to

\profile2\path$\delete

So you have to split the source path and join it then how you need it. You should read the help for Split-Path and Join-Path and maybe about_split.

You should show the code you already have. We can help you with improving your code but we will not write ready to use code from scratch for you. And please format code and sample data as code using the pre tags (with the buttons above the edit box). Thanks

[quote quote=143286]So you have to split the source path and join it then how you need it. You should read the help for Split-Path and Join-Path and maybe about_split.

[/quote]

Great! Will be reading about them tomorrow. Thanks.