Skip to main content


Showing posts from January, 2015

Creating files with powershell

There comes a time when you need to create files with powershell. Search the web and you will find many solutions. Here I am going to list a few of you options. First one up is from the Powershell Magazine by Shay Levy: It is a basic functions with some parameters for you to change the path where the file should be written and the size of the file. Second is from another blog Nate Jones. It is a couple of lines with code for you to run: Third is from Jeffery Hicks. He also use the [IO.File] .Net class to create an advanced function that also supports pipeline input. His function requires Powershell version 4: Click the pictures to find the article about each solution. If you search for your self, you will see pretty much all kinds of variations around the .Net class System.IO.File. Natively in Powershell to my knowledge there is no single cmdlet that lets you create files of an predefined size. So lets dig around and see what we can find. First we need to di

Operations Manager–Gateway servers and failover with Powershell dynamic parameters

Been thinking about doing a post about failover in SCOM with gateway servers. The idea is that you have several (2 or more) SCOM management servers in your management group. As you start to build your first gateway server, the question about failover/high availability for the gateway comes walking down the street. No problem, powershell comes to the rescue and provides you with a cmdlet you can use – Set-SCOMparentManagementServer . All nice and dandy, however you can only set the primary management server or the failover server, not both at the same time. In addition you have to provide the cmdlet with gateway and management server objects. You cannot just specify their names. These are by no means huge issues, however I wanted to play around with the dynamic parameter in Powershell and decided to get to work. Just a fair warning. Dynamic parameters are not pretty in Powershell, however if you put a little effort into the logic, it is quite reasonable to understand. What do