I need to create a script that asks the user to input a folder name\path $File. From that $File aquire a subfolder name e.g. $File\docs\ref\$host. Then copy $host to a new network share and create that folder name of $host and paste its contents in there.
The reason I can't just copy $host is because $host name changes as does $File but the subfolders inbetween the 2 are the same.
I hope that makes sense?
This is what I have:
$file = Read-Host -Prompt 'What is your folder?'
# This is where I'm stuck
$host = Read-Host $file\docs\ref\$host
Test-Path \\Hulk\note\$host
If false
MD \\Hulk\note\$host
Copy-Item –Path $file\docs\ref\$host\ -Destination \\Hulk\note\$host\ –Recurse
$hostin$file\docs\ref\$hostcome from? And why are you usingRead-Hoston it? Also,$hostis an automatic variable that contains information about the host process. You're not supposed to modify it. - Ansgar Wiechers$file = Read-Host -Prompt 'What is your folder?'will contain folder name not in $Host - DisplayName