Archive for the ‘System’ Category
How To Update Configuration Manager Site Code With PowerShell
Did you move domains recently or reconfigure your System Center Configuration Manager (SCCM)? Maybe you’ve found your Config Manager site code broken. Here’s a one-liner that shows you How to update a sitecode for SCCM with PowerShell.
This assumes that you’ve got SCCM running, and installed on the client. I found this problem hanging around on our machines after a migration from an old domain into the new domain. Each domain had Microsoft Configuration Manager installed on it, and each domain had a different site code. A domain wide group policy was used to install the client in each domain, but I had problems with the site code for the old domain still on the Configuration Manager client after domain migration was complete.
Luckily, we can use PowerShell to change the site code, and we can even use PowerShell to discover published site codes.
First we need to grab hold of our SMS client. In PowerShell, it couldn’t be easier:
$sms = new-object –comobject “Microsoft.SMS.Client”
We can use the methods of the Microsoft.SMS.Client class by using PowerShell to directly work with the SMS client object:
$sms.SetAssignedSite(“ABC”)
or find out what the site code is currently set to:
$sms.GetAssignedSite() # This returns a string value
Since the GetAssignedSite() method returns a string, it can be used in scripts to verify the site code is correct. I use this on scripts (pushed via Group Policy on the domain roots) to verify the site code is correct, and correct the site code automatically if it is wrong.
Since I know the site code, let’s say “ABC” is the new domain and “XYZ” is the old domain, I would use this:
$sms = new-object –comobject “Microsoft.SMS.Client”
if ($sms.GetAssignedSite() –ne “ABC”) { $sms.SetAssignedSite(“ABC”) }
Finally, I’ll call attention to another method of the SMS Client object: AutoDiscoverSite()
AutoDiscoverSite returns a site code for the Active Directory Domain (if published)
$sms = new-object –comobject “Microsoft.SMS.Client”
if ($sms.GetAssignedSite() –ne $sms.AutoDiscoverSite() ) { $sms.SetAssignedSite($sms.AutoDiscoverSite()) }
Now just a little clean up here…
Write-host “Thanks for reading. Subscribe! Or, connect via Twitter or Facebook. Ask questions to twitter using #poshhelp or #powershell to get q’s answered fast!”
$null = $thisBlogPost
Automate Dell Support With PowerShell, Part 1: Open Dell’s Site With System Tag Automatically
Are you tired of entering the system tag information by hand on Dell’s support web site? You want a fast and easy way to automate Dell support with PowerShell. I’ll show you how to Automate Dell Support With PowerShell in this life changing series!
This week, we’re learning how to open Dell’s support site with the system tag filled in automatically.
If you previously read my post on getting the Dell System Tag from WMI you may have, like me, come away from it with one big problem. In the article, I say that you can enter the system tag into Dell’s support page. That is a little lame, don’t you think? Audacious, in fact, to suggest that a PowerShell user should have to do anything!
So, with my apologies, here is a very quick improvement to help you get to your Dell Support Page that much faster.
How To Open Dell’s Support Page with the System Tag Already Filled In
function popup-Dellinfo
{
$systemtag = (gwmi win32_bios).serialnumber#Thanks to Jeffrey Snover for pointing out the Win32_BIOS class
$ie = new-object -com "InternetExplorer.Application"
$webaddress= [string]::Format("
$ie.Navigate($webaddress)
$ie.visible=$true
}
Drop that function into PowerShell, or add it to your PowerShell profile.
That’s pretty good, but I think it can be better.
To see it go from this rudimentary function to something more robust come back next week. Or subscribe to this blog and read it the day it comes out in your RSS reader!
How To Find Dell System Tag Using PowerShell
I administer a lot of computer brands, and support a wide ecosystem. But I see a lot of Dell Laptops, Desktops
, and Servers in my normal day-to-day. A common task is to rebuild a system, or to update a driver after troubleshooting blue screens.
When it’s time to download drivers, there’s one sequence of events that I don’t want to do anymore:
- Turn over laptop
- Read the serial number
- Tell myself “I got this”
- Stare at the serial number
- Memorize the serial number
- Turn the laptop back over, and enter the serial number onto the support webpage
- Forget the stupid serial number halfway through (cause it’s the serial number that’s stupid, not me, right?)
- Repeat steps 1-7 again (do step 8 only one time. If today is Monday and you have not had coffee yet, do step 8 two times)
- Fine! Write down the stupid serial number
- Tell myself “No problem – I told you I got this”
Now that I’m more refined in my technique, I can show you my simple way to find the serial number or system tag of a Dell computer by using PowerShell:
get-wmiobject Win32_SystemEnclosure | select SerialNumber
That actually returns a PSCustomObject. Now, you might want to get right at the string value instead. If you’re putting the computers serial number or system tag through the pipeline, or saving it to a file, then you should use this instead – it will return just the string value stored in WMI.
(gwmi Win32_SystemEnclosure).SerialNumber
Here, we invoke the alias for get-wmiObject, gwmi. It is exactly the same, just fewer keystrokes. Then, we use the parenthesis to turn it into an object, and put the “.” (dot) there to get access to the properties.
This can also be used to get the system tag for a remote system by using the –computername parameter on the get-wmiobject cmdlet
gwmi win32_systemenclosure –computername remotesystem-pc
This is the best way that I’ve found to get the information from a Dell computer. You can use the Service Tag on their website to get up to date drivers and warranty information.
How to Identify Uninstaller Information From Registry Keys
If you want a fast way to get information about the uninstallers that are listed in the registry, then check out this simple script to parse out some information for you.
This little baby asks you for a search term, then grabs the pertinent software uninstall information out of the HKey Local Machine registry hive.
It’s simple and effective, and I put it together in just a couple of minutes. It could stand to have some polish on it, but it does the job and it does it like now!
Would you improve it? How? Comments are open.
How to Setup a PowerShell Script to Run as a Scheduled Task
Alright, so you’ve built up your skills, developed your script, got all the kinks worked out and now it’s time to set the sucker up to do your work for you. I know, I’ve been there myself.
This tutorial shows you how to setup a scheduled task to run your PowerShell scripts’
Free PowerShell Tutorial – How To Create A New File Each Day With PowerShell
If you need to automate a task to create a file once a day, this PowerShell tutorial will help.
This problem is handled in 2 parts: Doing the task you want to do; and saving the output.
