Populate Hash Table from a Read-Host input


we have form use collect info new staff. looking way use info collected on feed powershell script automate as possible. today form submits email info collected in body of email. hoping able copy line email , paste in powershell read-host input line in powershell script , load hash table. think can format line needed thinking like

name = "lomond, stephen";company = "abc";department = "it"

this hoping use cannot see work

$newuserline = read-host "enter user info"

#i know below line not work trying figure out
#$newuser = @{$newuserline}

#i know line works cannot seem take input read-host
$newuser = @{name = "lomond, stephen";company = "abc";department = "it"}

$newuser.name
$newuser.company
$newuser.department

any input welcome.

not sure if best way approach this, works

$newuserline = read-host "enter user info"  $newuserline = $newuserline.split(';') $name = $newuserline[0].split('=')[1].trim() $company = $newuserline[1].split('=')[1].trim() $dept = $newuserline[2].split('=')[1].trim()  $newuser = @{name=$name;company=$company;department=$dept}  $newuser.name $newuser.company $newuser.department


if find post has answered question, please mark answer. if find post helpful in anyway, please click vote helpful.

don't retire technet



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

DCOM received error "2147746132" from...

ADFS 3.0 Event ID 4625 | An Error occurred During Logon | Status: 0xC000035B

DFSR RPC replication errors 5014 1726 with large files over VPN