I will try and outline this in the clearest way possible but it may be confusing so bare with me. Hopefully it makes sense and it can be done, without too much tinkering around.
Currently trying to develop a script to automate some configuration tasks of new computers that were just imaged using a basic menu script that allows the tech to select option 1 and it executes the corresponding task so on and so forth.
Here are some of the tasks:
- Running Windows updates with PSWindowsUpdate Module
- Change Computer Name
- Move New Computer Object from Computers OU to Proper OU
- Activate Windows and Office
- Join computer to Domain
Now I know the commands in which I need in order to execute these tasks with but I am having a bit of trouble with the logic and the best way to go about it.
-
Windows update
import-module PSWindowsUpdate Get-WUInstall -NotCategory "Language Packs" -AcceptAll -IgnoreRebootRequired
Issue I AM having is that this module only works on the local machine, all well and fine, I can deal with that
-
Change computer name (Most of these new computers have an image that comes with PS 2.0)
Set-Variable(Get-WmiObject win32_computersystem).rename($compName); Restart-Computer -Force
All well and good here.
-
Move New Computer Object from Computers OU to Proper OU
Move-ADObject “CN=$computer,OU=Computers,OU=Faculty,OU=xxxxxx,DC=xxxxx,DC=xxxxx” -TargetPath “OU=Computers,OU=IT Personnel,DC=xxxx,DC=xxxx”
Now I can import the module to the newly imaged computer, if im doing this from my own machine using: <pre class="prettyprint">$session = New-PSSession -ComputerName $computer invoke-Command { Import-Module Activedirectory } -Session $session</pre> But as you can see I cannot figure out a way to logically have both options 1 and 3 in the same script as I need to run the Windows update command locally on the newly imaged computer but I cannot import the Active Directory module into the newly imaged computer easily without downloading the remote administration toolkit (at least I havent figured out how yet). So I am having this battle with should I try and do this all remotely from my actual computer and just use PSSessions to invoke all these commands or do I make script that I copy to each computer I want to image and run everything locally.
Any help will be appreciate, even if its telling me im just running in circles and this script wont benefit anything. Im learning powershell and just trying to help automate some things in my free time