I wanted to append information to the verbose output of a cmdlet so that logging is neater. Well, it seems there is no nice way to do that?

This is what I came up with, redirecting the verbose stream, manipulating the verbose string, and then write it verbose back out

Source: https://blogs.technet.microsoft.com/heyscriptingguy/2014/03/30/understanding-streams-redirection-and…

You might not even notice until you need it, but when you install the RSAT tools on Win 10 for 1709, the DNS manager console is missing. That’s exactly what happened to me. I needed to add some records in DNS and oops, where is it?

Well, there is a KB article on it, so there is a fix. :¬)

  1. Check if KB 2693643 is installed, if so uninstall it
  2. Create a temporary directory to put stuff in it
  3. Create a “installx64.bat” file with the following content: [assuming you run a 64 bit Windows]

    4. Create a “unattend_x64.xml” file with the following content:

    5. Download the RSAT tools and put the msu file in the same folder

    6. Start a command prompt with administrative permissions and run the “installx64.bat”

    Once completed, you should have your full set (including DNS) of RSAT tools back

    Resource: https://support.microsoft.com/en-us/help/4055558

I keep seeing many posts with people struggling to execute code on remote machines, it is usually not due to permissions issues, (enable PS Remoting), but mainly due to the fact that they forget that the remote machine does not know the value of the locally assigned variable.

Using (new way) PSv3+

With PowerShell Version 3 and newer, $using was introduced.
If you want to pass a local variable to the remote machine , just add $using: in front of the variable name (e.g. $using:localvariable), and the local value will be given on to the remote machine. This is so much simpler and easier to read than the ‘old’ argumentlist way.

Argumentlist (old way)

In this sample, we are looking at using an argument list to pass the values of the variable to the remote machine.
You define the values you need per usual on your local machine, and then you add an $argumentlist as parameter.
The order you list the variables is important, as the one first variable listed is addressed with $args[0], the variable next to it (to the right) is addressed with $args[1] and so forth.

 

Reference: about_remote_variables