It seems like one of the other admins is always adding a computer to the domain and not telling me, and I realized that I need to make it a priority to check the "Unassigned Computers" container every so often to ensure there isn't anything in it. This is the sort of thing Powershell shines at!
Before you run this, make sure you have a C:\Temp folder, or change the output file path. I did my explanation in the comments within the script below:
$WsusServer = "WSUSServer.contoso.com"
$UseSSL = $false
$PortNumber = 80
$TempFile = "C:\Temp\Output.txt"
#E-mail Configuration
$SMTPServer = "SMTPServer.contoso.com"
$From = "administrator@contoso.com"
$To = "me@contoso.com"
$Subject = "PS Report - Unassigned Computers in WSUS"
#Connect to the WSUS 3.0 interface.
[reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") | out-null
$Wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer($WsusServer,$UseSSL,$PortNumber);
#Get the FQDN of computers that reside in the Unassigned Computers container
$Unassigned = (($Wsus.GetComputerTargetGroups() | ?{$_.Name -eq 'Unassigned Computers'}).GetComputerTargets() | select FullDomainName)
#Output each to the temp file
Foreach ($Computer in $Unassigned){
($Computer.FullDomainName) | out-string | add-content $TempFile
}
#Create the body of the email, inserting <BR> tags between each line.
$Body = (Get-Content $TempFile) -join '<BR>'
#If there are computers in the unassigned computers group, send me an email listing them
If ($Unassigned -ne $null){
Send-Mailmessage -From $From -To $To -Subject $Subject -SMTPServer $SMTPServer -Body $Body -BodyAsHTML
}
#Delete the temp file
Remove-Item $TempFile -ea silent
One of the challenges I faced here was getting the computer names into the text file. Out-String didn't work because of the type of object the $Unassigned was, for some reason. I ended up outputting to the temp file, then using -join to put in <BR> tags, then sending the email with the BodyAsHTML option. In HTML, the <BR> tag just represents a carriage return (go to the next line).
Click an Ad
If you find this blog helpful, please support me by clicking an ad!
Monday, June 24, 2013
Friday, June 21, 2013
Grep for Windows - What a Welcome Tool!
Last week we renamed a file server, and I needed to dig through all of my Powershell scripts and change the name wherever it was referenced. What a tedious chore!
Oh how I wished there was a tool that would search inside of multiple text files and tell me where a string of text appears!
THERE IS!
It's called Grep for Windows, and it is awesome. It's wizard driven and will even search based on regular expressions.
Oh how I wished there was a tool that would search inside of multiple text files and tell me where a string of text appears!
THERE IS!
It's called Grep for Windows, and it is awesome. It's wizard driven and will even search based on regular expressions.
Wednesday, June 19, 2013
Windows 8 - Mini-Review, and My Ability to Switch Users went Missing!
I'll get to the actual fix towards the bottom, but let me diverge into my mini-review of Windows 8 for a couple of paragraphs first.
This weekend I took the plunge and installed Windows 8 on my home desktop. I took full advantage of that promo that Microsoft had back in January and picked up Windows 8 for $30. I still think Windows 8 is a "failure" for the business segment due to so many business users being, well, fairly clueless when it comes to technology. I also have come to believe that humanity in general despises change and lacks a yearning to learn new things, especially when the old way "works just fine". Okay, enough sociology.
I've been using Windows 8 for a few days now, and let me tell you: It has some great features! While the switch to the Metro interface (Start Screen) is jarring, I like that I have big buttons for my most used apps. One of the fixes in 8.1 is that you can make the wallpaper on your Start Screen the same as your desktop wallpaper, so that should help. The live tiles are less useful on a desktop, but I can see their allure. Some of the built in apps are pretty barebones, but there's a store and I can get more apps. The first thing I found was TuneIn, which lets me listen to terrestrial radio stations from all over the planet - awesome! Half the time when I hit the start button on my keyboard I am typing the thing that I want to open anyway, so my use of the start screen is fairly limited. One thing I overlooked about the big buttons is the ability to "remind" myself that I need to do something, like check my torrents, for instance. When I press start now there's my big green uTorrent button staring at me.
The second thing that I really like is the parental control. I have a 12 year old, and now I can look at where he's going on the web independent on whether he figures out how to clear his history. I hear you now: "But why don't you just set up a Squid proxy or something - you're a geek!" This is an option I have thought of many times, but I don't want to pay the electric bill and deal with the management (at home, no less) of yet another system. I also have him locked down with an application whitelist, so that he can only run things I say that he can ahead of time. The cherry on top is that I can specify when he can log on, so no more worrying about him sneaking down in the middle of the night. I'm pretty sure I could have done this via group policy before, but I like that it's now an easy to find option.
So, I got this thing all configured and then I noticed that I didn't have the ability to "switch user" anymore. What was odd is that it was working just fine. I have no idea what caused it to go away since I was doing so many thing (it's a new install after all). After hunting around I finally found a group policy option that fixed the problem.
1. Hold down your Windows key and press 'R' to open the Run Command box.
2. Type 'gpedit.msc' and press enter. This open Group Policy Management.
3. Navigate to Local Computer Policy/Computer Configuration/Administrative Templates/System/Logon
4. Within the Logon folder, you will see "Hide Entry Points for Fast User Switching". Right-click on it and select Edit.
5. Change the setting to "Enabled" and then press OK.
6. Close the Local Group Policy Editor
7. Hold down your Windows key and press 'R' to open the Run Command box.
8. Type 'gpupdate /force' and press enter, then wait for the black box to go away. Or you can reboot.
That's it.
This weekend I took the plunge and installed Windows 8 on my home desktop. I took full advantage of that promo that Microsoft had back in January and picked up Windows 8 for $30. I still think Windows 8 is a "failure" for the business segment due to so many business users being, well, fairly clueless when it comes to technology. I also have come to believe that humanity in general despises change and lacks a yearning to learn new things, especially when the old way "works just fine". Okay, enough sociology.
I've been using Windows 8 for a few days now, and let me tell you: It has some great features! While the switch to the Metro interface (Start Screen) is jarring, I like that I have big buttons for my most used apps. One of the fixes in 8.1 is that you can make the wallpaper on your Start Screen the same as your desktop wallpaper, so that should help. The live tiles are less useful on a desktop, but I can see their allure. Some of the built in apps are pretty barebones, but there's a store and I can get more apps. The first thing I found was TuneIn, which lets me listen to terrestrial radio stations from all over the planet - awesome! Half the time when I hit the start button on my keyboard I am typing the thing that I want to open anyway, so my use of the start screen is fairly limited. One thing I overlooked about the big buttons is the ability to "remind" myself that I need to do something, like check my torrents, for instance. When I press start now there's my big green uTorrent button staring at me.
The second thing that I really like is the parental control. I have a 12 year old, and now I can look at where he's going on the web independent on whether he figures out how to clear his history. I hear you now: "But why don't you just set up a Squid proxy or something - you're a geek!" This is an option I have thought of many times, but I don't want to pay the electric bill and deal with the management (at home, no less) of yet another system. I also have him locked down with an application whitelist, so that he can only run things I say that he can ahead of time. The cherry on top is that I can specify when he can log on, so no more worrying about him sneaking down in the middle of the night. I'm pretty sure I could have done this via group policy before, but I like that it's now an easy to find option.
So, I got this thing all configured and then I noticed that I didn't have the ability to "switch user" anymore. What was odd is that it was working just fine. I have no idea what caused it to go away since I was doing so many thing (it's a new install after all). After hunting around I finally found a group policy option that fixed the problem.
1. Hold down your Windows key and press 'R' to open the Run Command box.
2. Type 'gpedit.msc' and press enter. This open Group Policy Management.
3. Navigate to Local Computer Policy/Computer Configuration/Administrative Templates/System/Logon
4. Within the Logon folder, you will see "Hide Entry Points for Fast User Switching". Right-click on it and select Edit.
5. Change the setting to "Enabled" and then press OK.
6. Close the Local Group Policy Editor
7. Hold down your Windows key and press 'R' to open the Run Command box.
8. Type 'gpupdate /force' and press enter, then wait for the black box to go away. Or you can reboot.
That's it.
Tuesday, June 18, 2013
Windows Updates for Labs Without an Internet Connection
I'm often building lab environments that have no ability to get online. This is usually because some of the VMs I build have the same name as actual production systems. Some of them are even restores of production VMs in a lab environment. Naming conflicts suck, especially in the middle of the day.
I found a great tool called WSUS Offline Update that lets me put all of the WSUS updates I want onto a virtual DVD and update my OS from it. I wish I had it back in the day when I was updating remote offices on a slow and shared internet connection! It's well-built and fairly granular - you can pick and choose OS, Architecture, etc. It will even do Office and .NET!
I found a great tool called WSUS Offline Update that lets me put all of the WSUS updates I want onto a virtual DVD and update my OS from it. I wish I had it back in the day when I was updating remote offices on a slow and shared internet connection! It's well-built and fairly granular - you can pick and choose OS, Architecture, etc. It will even do Office and .NET!
Subscribe to:
Posts (Atom)