How do i get user computer name by username
dear professional,
need ur usual assistance in powershell to develop script windows 7 machine know computer typing username.
ilyas mohammed
dunbar thx feedback,
how have same scenario
support@mytechnet.me
i gave outline of process, here in little more detail:
an admin runs powershell script:
- prompts name of user:
$username = read-host "enter user's name" - creates vbscript in share on server (more on later)
vbscript code created double-quoted here string - creates body of email message double-quoted here string
includes html code present link vbscript - extracts info user (first/last name, email address, phone#) active directory
- sends user email:
send-mailmessage -body $body -bodyashtml -subject $subj etc.... - displays series of periods progress bar while waiting .csv file created.
the user receives message and:
- clicks on link clicks on open button to run vbscript
the vbscript runs and:
- determines name , ip of user's computer
- writes along username , date .csv file @ same location , same name vbscript.
- deletes itself
back @ admin's computer
- when powershell script sees .csv file exists, imports computer name , ip.
$compinfo = import-csv $csvfile
$compip = $compinfo.ipaddr
etc... - launches sccm remote control applet directed @ either computername or ip address:
if ( test-connection $compname -quiet ) {
rc.exe 2 $compname
} else {
rc.exe 2 $compip
}
i cannot share code because specific our environment , contain number of details of no importance you. arduous trim down basics you. well, not know parts of problem , easy.
if start building script , stuck on parts of it, try answer (as others). when i'm @ work tomorrow, i'll try post of code might helpful, like, example, vbscript itself, , powershell code creates it.
if unfamiliar of components used, read-host, import-csv, send-mailmessage, , accessing active directory, i'd suggest write smaller scripts play them before tackling whole project.
al dunbar
Windows Server > Windows PowerShell
Comments
Post a Comment