Jump to content


  • 0
Danie

Using Powershell to add Comp Desc

Question

Hello Windows-Noob Folks,

 

Followed this topic

 

https://www.windows-noob.com/forums/topic/11797-using-powershell-to-apply-task-sequence-variables/

 

To add the description in AD Computer. What I have done defined as below,

 

1. Created Powershell Script

#Create OSD Task Sequence Environment Object
$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
#Get the ComputerDescription
$strComputerDesc = $tsenv.Value("OSDComputerDesc")
#Computer Name
$strName = $env:computername
#Get PSSession Credentials
$strUser = "domain\user"
$strPassword = "passw0rd"
#Connect to Remote PowerShell Session
#Set Active Directory Properties
$pw = ConvertTo-SecureString -AsPlainText -Force -String $strPassword
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "$strUser", $pw
$s = New-PSSession -Computer SERVER -Credential $cred
Invoke-Command -Session $s -Script { Import-Module ActiveDirectory }
Invoke-Command -Session $s -ScriptBlock { Set-ADComputer -Identity "$using:strname" -Description "$using:strComputerDesc" }
2. Created a Package (Not Program) and uploaded to DP
3. Now, How do I adds this in Task Sequence??
At first, I added as Run PowerShell Script but it won't worked out. :(
Second do I run as Run Command Line and add these line in TS
CMD.EXE /C %SYSTEMDRIVE%\windows\system32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -file .\ADpowershell.ps1
post-25316-0-46778300-1460460711.png
What is the preferred way to do this?
Thank you.

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.