I addressed a reader requested script for my article this week. PowerShell gives you the ability to add computers to Active Directory right from the command line with the built in PowerShell commandlets. This was introduced with PowerShell version 3 and can be used to automate imaging processes or to prompt an agent for the desired computer name and organizational unit. This is useful since a lot of organizations will use specific OUs for computers according to location or department. This allows them to set group policies that apply to those computer accounts accordingly. By default these computer accounts are created in the root Computers OU, but creating an account can be targeted. The highlighted examples should provide you everything you need to tackle that use case. I provide the basics of adding a computer to the domain as well as prompting the user to enter the computer name and location. Head on over to PowershellBlogger.com for the full write up and thanks for everyone’s continued support!
I am back this week with some more Exchange and Unified Communications goodness. This is another request I see a lot, someone want’s to know where an e-mail address is assigned. This opens up the possibilities of user mailboxes, shared mailboxes, distribution lists, public folders, conference rooms, contacts or resources. I have also seen duplicate e-mail addresses being assigned outside of Exchange causing delivery failures. I take a look at how you can quickly find any e-mail address in your environment along with partial searches of e-mail addresses. The two attributes for e-mail addresses being mail and proxyAddresses.
Do you feel that writing tests is confusing, and you often end up with complicated test code? I did too, before I learned about Command-query separation principle (or CQS). This principle lead me to start thinking about data flow directions in tests and in the end I realized there are few basic patterns that I use in my test code over and over.
Command-query separation principle
The command and query separation principle tells us that we should separate commands from queries (duh!). To do that, we first need to learn the difference between a command and query: A command is a function that has an observable side-effect and returns no result. A query is the opposite. A function that has no observable-side effect, and returns a result. https://gist.github.com/nohwnd/fb5616fb92995555480c The call to Set-Variable has a side effect of creating a variable named “a” and setting it to value “1”. This side effect is clearly observable, because we had no variable $a before the call and now we have one, so Set-Variable must be a command. Also the Set-Variable does not return any output which should be another clue (unless you provide the -PassThru parameter, more on that later). The other call, the call to Get-Variable, has no observable side effect. You could call it once or 100 times and that would have no effect on the value of the $a variable. Plus the Get-Variable returns a result so it must be a query. PowerShell also gives us another clue whether a function is a command or query with the Verb used for that function. Anything with Set, Add and New verb is supposed to be a command. Anything with Get verb should be a query. Understanding the difference between commands and queries is important, because data flows through them in opposite directions, and so you need to test them differently.
Lately, I’ve been working at converting a lot of my server configuration scripts into DSC configurations. After all, what better way to learn than by updating your existing methods? I recently ran into an issue, however, while converting my SCCM Distribution Point deployment script into a config, where the test systems inexplicably began rebooting every thirty minutes or so. The Local Configuration Manager was configured to reboot if necessary, and these were fresh installs, so I knew that my culprit was most likely in my configuration.
Hey now! The PowerShell team published a preview version of PackageManagement for Windows PowerShell v3 and v4. As it happens, I have a Windows 7 SP1 box running PowerShell v3–why not run a little experiment?
`$PSVersionTable.PSVersion
Major Minor Build Revision
3 0 -1 -1
`## Preparing the Environment
You need .NET Framework 4.5 or later, so take care of that prerequisite before you install the following two assets:
Name changes are a common occurrence in the world of IT and usually the primary concern is the e-mail address. Exchange e-mail address policies will handle this for us but often times the Sip Address and User Principal Name are left behind. I tackle these changes with an automated way of changing the Lync / Skype for Business sip address (also known as sign-in address) and User Principal Name to match the e-mail address. I also include the link to download the Lync / Skype for Business meeting update tool that is required when a Sip Address is changed. Head on over to PowerShellBlogger.com for the full article.
I am back this week with a quick write up on how to export your network subnets from Active Directory Sites and Services. Active Directory Sites and Services subnet assignments are important for healthy replication and for location based services to function properly. The need for this information has come across my desk on several occasions. Even a quick print out would be extremely helpful to keep at your desk. I have included both Windows 7/2008 and Windows 8/2012 methods to ensure everyone is covered. Head on over to PowerShellBlogger.com for the full article. As always, leave a comment and I will be sure to respond.
Hey there! I thought we could test PowerShell Direct together today. Here’s the elevator pitch: In Windows Server 2016 and Windows 10, we can send PowerShell commands from the Hyper-V host directly to its corresponding virtual machines (VMs), even in the absence of guest VM networking. Yeah, that’s cool, isn’t it?
What’s just as impressive is that PowerShell Direct works _even if PowerShell remoting is disabled on the guest VM! _PowerShell Direct also circumvents Windows Firewall. Note that PowerShell Direct requires that commands are sent only from a Hyper-V host to its local VMs.
Have you ever wondered what LDAP queries were hitting your domain controllers? Even outside of fun investigations, it can be insightful to get a sampling of queries hitting your domain controller. The more services you have integrated with Active Directory, the more likely a vendor or sysadmin unwittingly configured their service to produce evil queries.
Mark Morowczynski from Microsoft wrote a great post on finding these expensive, inefficient, or long running queries - But something was missing. Screen shots of regedit? If you have more than a handful of domain controllers, enabling and disabling this logging is going to be quite a chore.
Well this is week number two in my quest to post an article once a week and I am back with a common request for Exchange administrators. There are a lot of scenarios that bring up a need to remove an e-mail or e-mails from all mailboxes in your environment. Perhaps there was a disgruntled employee, a virus outbreak, or a reply all to the whole company. We all know that the “Retract” button is best effort (yes I still miss GroupWise for that purpose).