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]] 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.


Reply via email to