Trevor, you da man! Thanks! If my employer ever sends me to TechEd, I owe ya a beer (or 2). :)
Mike From: [email protected] [mailto:[email protected]] On Behalf Of Trevor Sullivan Sent: Friday, May 16, 2014 10:50 AM To: [email protected] Subject: RE: [mssms] Powershell help I made some modifications to the code below, including a Write-Verbose statement that progressively reports progress of creating the resulting password. Function Get-TempPassword { Param( [int] $Length=10, [Parameter(Mandatory = $true)] [string[]] $SourceData ) For ($i=1; $i –le $length; $i++) { $NewChar = $sourcedata | Get-Random; Write-Verbose -Message ('Adding {0} to {1}' -f $NewChar, $TempPassword); $TempPassword += $NewChar; } Write-Output -InputObject $TempPassword; } $ascii=$NULL;For ($a=33;$a –le 126;$a++) {$ascii+=,[char][byte]$a }; $Password = Get-TempPassword -Length 19 -SourceData $ascii -Verbose; Write-Host -Object $Password; Results: [cid:[email protected]] Cheers, Trevor Sullivan Microsoft PowerShell MVP From: [email protected]<mailto:[email protected]> [mailto:[email protected]] On Behalf Of Murray, Mike Sent: Friday, May 16, 2014 12:14 PM To: [email protected]<mailto:[email protected]> Subject: RE: [mssms] Powershell help I don’t think the data type is the issue. The function works, the $TempPassword value is just blank outside of the function. I need to have access to that value. From: [email protected]<mailto:[email protected]> [mailto:[email protected]] On Behalf Of Daniel Ratliff Sent: Friday, May 16, 2014 9:14 AM To: '[email protected]'; '[email protected]' Subject: RE: [mssms] Powershell help $ascii is null but the sourcedata parameter requires a string. Not sure if it will accept a null value. Take off the string data type from the parameter and see if it helps. -Daniel Ratliff -----Original Message----- From: Murray, Mike [[email protected]<mailto:[email protected]>] Sent: Friday, May 16, 2014 11:57 AM Eastern Standard Time To: [email protected]<mailto:[email protected]> Subject: [mssms] Powershell help Hey folks, I’m trying to set a local admin password with a random value in OSD. I found this function online that is great, but I can’t seem to return the value outside the function. I’ve tried a bunch of ways with no luck. Can someone help? The colde below doesn’t have the setting of the password, I just want to see that the password variable is returning and I can use it in the change command. Function GET-Temppassword() { Param( [int]$length=10, [string[]]$sourcedata ) For ($loop=1; $loop –le $length; $loop++) { $TempPassword+=($sourcedata | GET-RANDOM) } return $TempPassword <-- this value does display } $ascii=$NULL;For ($a=33;$a –le 126;$a++) {$ascii+=,[char][byte]$a } $PW = GET-Temppassword –length 19 –sourcedata $ascii write-host $PW <-- this is empty Best Regards, Mike Murray Desktop Management Coordinator - IT Support Services California State University, Chico 530.898.4357 [email protected]<mailto:[email protected]> The information transmitted is intended only for the person or entity to which it is addressed and may contain CONFIDENTIAL material. If you receive this material/information in error, please contact the sender and delete or destroy the material/information.

