I'm currently trying to get to grips with powershell and on a previous script I made i was doing a couple of silly things, editing values of text files, only to tell powershell to get those values again. I've stayed up late last night watching tutorials but was struggling to find a method for this, and was looking for some help in the correct way to do the below
The Aim
Get the script to edit the value of a variable, the variable includes the home directory properties of a test account
What i have currently
{
Do {
$name = Read-Host 'Enter the required Log on ID'
} Until ($name)
$drive = Get-ADUser $name -Properties * | select homedirectory
$drive = $drive -replace 'homedirectory', ''
$drive
The initial variable is
homedirectory
-------------
\\WIN-7V7GI0R7CFK\homedrives\Onetest$
And after using the replace funtion it turns into
@{=\\WIN-7V7GI0R7CFK\homedrives\Onetest$}
Please see the attached screenshot, I am looking for the $drive
variable to just be the drive path, which in this case would be \WIN-7V7GI0R7CFK\homedrives\Onetest$
Any help is appreciated, just looking for the correct method in tying all this together so i can incorporate this into other parts of the script if necessary