I am very new to Powershell, Started today actually, and I need some help with getting a command to display output. The command works when run from powershell but when I try to run from my script I pasted it seems to fail. I've even changed the variable field to my username and it still fails.
Get-ADUser jdoe -Properties Description
Like I said it works when run in powershell but not when run in a script.
Clear-Host
$script:ChosenFunction=Get-function #Get-Choice
function Get-function
{
Write-Host "1. IP (future addon)"
write-host "2. UserInfo"
write-host "3. CopyZ (Future addon)"
write-host "4. Local Users (Future addon)"
Write-Host "X. Exit"
$Action=Read-Host "Choose an action:"
Switch ($Action)
{
1 {$Choice="IP"}
2 {$Choice="UserInfo"}
3 {$Choice="CopyZ"}
4 {$Choice="Local Users"}
5 {$Choice="Exit"}
}
write-host "Function chosen is $Choice"
if ($Action -eq 2)
{
write-host "if is working"
$script:ChosenFunction=userInfo
}
}
function userInfo
{
cls
$Name=Read-Host "Enter user name: "
Write-Host "finding $Name"
Get-ADUser $Name -Properties Description # <---- Here's my problem get user's AD information
}