i have a variable $user which has an AD user stored in it. i want to change its UPN. if i write this on dc:
$user | set-aduser -UserPrincipalName [email protected]
it works fine. but if i use invoke command like so
Invoke-Command -Session $S -ScriptBlock {$using:ADUSER | set-aduser -userprincipalname [email protected]}
i get an error (assume $s is a good session, im using it in other lines) my error is:
The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input. + CategoryInfo : InvalidArgument: (CN=uzi,OU=IT,OU...shahar,DC=local:PSObject) [Set-ADUser], ParameterBindingException + FullyQualifiedErrorId : InputObjectNotBound,Microsoft.ActiveDirectory.Management.Commands.SetADUser + PSComputerName : dc01
edited: lines for aduser
$uname = $script:textbox1.text+"@"+$script:textbox2.text
$ADUSER = Invoke-Command -Session $S -ScriptBlock {Get-aduser -property 'emailaddress' -filter "UserPrincipalName -eq '$using:UNAME'"}
can anyone assist please?
$ADUSERis the samaccountname (e.g. jdoe1234) tryInvoke-Command -Session $S -ScriptBlock {set-aduser -identity $using:ADUSER -userprincipalname [email protected]}- Guenther Schmitz$AdUser... please add that to your code so that one can do something lore than make wild guesses ... [grin] - Lee_Dailey