Tag: PowerShell

TechSnips is Looking for Content and Recruiting Contributors

This blog article is the first guest post ever on this site. When I'm approached by someone who wants to write a guest blog article, I suggest that they should start their own blog. If they're simply not interested in that, I put them in contact with PowerShell.org because it seems like a more appropriate place to publish community blog articles. The majority of the posts on this site are simply the steps of how I've done something in a real-world production environment. I document the process here Read more [...]

Convert Scientific Notation to Decimal with PowerShell

Have you ever run into a problem where the results from a PowerShell command are returned in scientific notation? I've recently been working with performance counters in PowerShell and I've run into several scenarios where this occurs such as the one shown in the following example. In addition to returning the results in the previous example, they were also stored in a variable so the same value could be used throughout this blog article. Windows PowerShell Read more [...]

Configuring “Send As” Permission in Office 365 using PowerShell

You're the administrator of an on-premises Exchange Server 2010 environment that's in Hybrid mode. After migrating a few users to Office 365, you start receiving complaints that they're no longer able to send emails as their departments group. First, follow the instructions in one of my previous blog articles to "Connect to Office 365 using PowerShell". The following command grants John Doe the ability to send as the Facility Services group in Office 365. It's Read more [...]

Assign a License to an Office 365 User with PowerShell

There are several scenarios where you might need to assign an Office 365 license to a user. The specific scenario in this blog article is that you're migrating an Exchange Server 2010 on-premises environment to Office 365. The Exchange Server is already in hybrid mode. Users have been automatically created in Office 365 by synchronizing them from your on-premises Active Directory environment using Azure AD Connect. Users who haven't already had their mailbox moved to Office 365 will first need an Read more [...]

Connect to Office 365 with PowerShell

I've recently been working on a project to migrate an Exchange Server 2010 environment to Office 365. As with Exchange, there are several things that simply can't be done from the GUI in Office 365. This means that if you're the Office 365 administrator for your company, you'll need a certain level of proficiency with PowerShell to effectively do your job . While not requirements, this blog article is written using Windows 10 Enterprise Edition version 1803 and PowerShell Core version 6.0.2. All Read more [...]

Video: Recreate MOF based DSC resources as Class based DSC resources

Last month I presented a session on how to Recreate MOF based DSC resources as Class based DSC resources at the PowerShell + DevOps Global Summit in Seattle, Washington. The session seemed to be well received by the audience based on the feedback that I received from the attendees. The video from this presentation is now available. https://www.youtube.com/watch?v=MeO_9KDB958&feature=youtu.be&a= The code and slides used during the demonstration can be found in my presentations repository Read more [...]

Video: Writing Award Winning PowerShell Functions and Script Modules

Last month I presented a session on Writing Award Winning PowerShell Functions and Script Modules at the PowerShell + DevOps Global Summit in Seattle, Washington. The session seemed to be well received by the audience based on the feedback that I received from the attendees. The session was also completely full. I'm glad it was recorded so anyone who was unable to attend can watch it. The video from this presentation is now available. https://www.youtube.com/watch?v=d5x0Di52QZA The Read more [...]

PowerShell Core 6: ValidatePattern Custom Error Messages

Last week, I received a comment on my previous blog article from fellow Microsoft MVP Joel Bennett which referenced using an ErrorMessage parameter similar to how ValidatePattern works in PowerShell Core version 6. I knew I'd seen some discussion about this on GitHub, but I wasn't aware that it had made it into the production release. Joel's message is shown in the following image. I had to figure out how to use custom error messages with ValidatePattern. After all, that was the whole Read more [...]

Simplifying Parameter Validation in PowerShell with Private Functions

In my previous blog article, I described how to move code from ValidateScript to a private function for parameter validation in PowerShell. This all came about from a question I received in one of my sessions at the PowerShell + DevOps Global Summit a couple of weeks ago. I enjoy following up with attendees of my presentations when they have questions so I sent a message and a link to my previous blog article to the person who asked if that was possible. They responded by asking if it was possible Read more [...]

Moving Parameter Validation in PowerShell to Private Functions

While presenting one of my presentations at the PowerShell + DevOps Global Summit last week, I demonstrated why you wouldn't want to use ValidatePattern for parameter validation because of the useless error message that it returns when the input doesn't match the regular expression that's being used for validation. I then demonstrated how ValidateScript could be used to build a better ValidatePattern. I have an older blog article that details this process if Read more [...]

Remotely Uninstall ESET Antivirus with PowerShell

Recently, one of the companies that I provide support for switched from using ESET to a new antivirus vendor. The problem is that all of their servers had both ESET File Security and the ESET Remote Administrator Agent installed which needed to be uninstalled before installing the new antivirus agent. I determined that the following commands could be used to uninstall the applications. Running msiexec.exe /? shows the available options. Based on this information, Read more [...]

Adding Multiple Parameter Sets to a PowerShell Function

Sometimes you need to add more than one parameter set to a function you're creating. If that's not something you're familiar with, it can be a little confusing at first. In the following example, I want to either specify the Name or Module parameter, but not both at the same time. I also want the Path parameter to be available when using either of the parameter sets. Taking a look at the syntax shows the function shown in the previous example does indeed have two Read more [...]

Using Plaster to create a PowerShell Script Module template

I have a function in my MrToolkit module named New-MrScriptModule that creates the scaffolding for a new PowerShell script module. It creates a PSM1 file and a module manifest (PSD1 file) along with the folder structure for a script module. To reduce the learning curve of Plaster as much as possible, I'm simply going to replace that existing functionality with Plaster in this blog article. Then moving forward, I'll add additional functionality. For those of you who aren't familiar with Plaster, Read more [...]

Temporarily Disable the Azure AD Connect Accidental Deletion Protection Feature with PowerShell

You've implemented Azure AD Connect to synchronize accounts in your on-premises Active Directory environment to Azure AD. If you took the defaults while running the setup wizard for Azure AD Connect, then everything in your Active Directory environment is synchronized. If you decided to filter the synchronization later to only specific OU's (Organizational Units) in your Active Directory environment, you could run into a scenario where the number of deletions exceeds the default threshold of 500 Read more [...]

The PowerShell Iron Scripter: My solution to prequel puzzle 3

I've been working through the Iron Scripter 2018 prequel puzzles which can be found on PowerShell.org's website. In puzzle 3, you're asked to create a "reusable PowerShell artifact". To me, that almost always means a PowerShell function. One requirement is to pull information from the PowerShell.org RSS feed. Invoke-RestMethod which was introduced in PowerShell version 3.0 is the easiest way to accomplish that task. You're also asked to display the returned information in a way that allows the Read more [...]