Hey guys,
So, I'm new to Powershell, so I have no idea what's going on.
I'm trying to make a script to set up all the things we need for new users. Here's the code that I'm having trouble with...
$first = Read-Host 'What is the first name?'
$last = Read-Host 'What is the last name?'
$name = Read-Host 'What is the username?'
$pass = "Password!"
$UserFolder = "D:\User Folders\Meltzer\$name"
New-Item -Path $UserFolder -ItemType directory
Everything works, up until the last line. Then, it gives me this-
New-Item : Access to the path 'shaering' is denied.
At C:\Users\SHaering\desktop\Test.ps1:10 char:9
+ New-Item <<<< $UserFolder -ItemType directory
+ CategoryInfo : PermissionDenied: (D:\User Folders\Meltzer\shaering:String) [New-Item], Unauthorized
ssException
+ FullyQualifiedErrorId : CreateDirectoryUnauthorizedAccessError,Microsoft.PowerShell.Commands.NewItemCommand
I've tried using -Force, I've tried using -Credentials, and I'm kind of stuck. I think it has something to do with the :String tacked onto the end, but I really don't know. Anyone have any ideas? Thanks in advance!