Jump to content

Sign in to follow this  

Using Powershell to add Comp Desc

Recommended Posts

Hello Windows-Noob Folks,


Followed this topic




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
What is the preferred way to do this?
Thank you.

Share this post

Link to post
Share on other sites

Join the conversation

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

Reply to this topic...

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

Sign in to follow this  

  • Create New...