Category Archives: PowerShell

PowerShell Scripting

Windows Can’t Change Public Network to Private Network – solved

If you can’t change your Public Network to a Private Network on a Windows 10 PC or Windows Server 2012 box, I have the solution for you!

 

Short version… Run the following PowerShell commands as an Administrator. Modify the 2nd command to match the InterfaceIndex of the network you want to change from the first command.

Get-NetConnectionProfile
Set-NetConnectionProfile -InterfaceIndex 7 -NetworkCategory Private

I’m new to PowerShell (or “What’s PowerShell?”) and I need more info!

 

Are you having trouble connecting to your Windows 10 or Windows Server 2012 computer via RDP (Remote Desktop Protocol) or another service like TeamViewer? It may be because your active network is set to a Public network. The problem is that when you go to “Control Panel\All Control Panel Items\Network and Sharing Center” you are unable to change the Public Network to a Private network because it it “greyed out” or the dropdown is gone altogether.

This is what mine looked like:

Can't change Public Network to a Private Network on Windows 10 PC or Windows Server 2012

The best option I’ve found is a simple PowerShell command to fix it.

If you are new to PowerShell… Click on Start, scroll down to W, find the Windows PowerShell folder, click to expand it, now, *this is important*, RIGHT click on Windows PowerShell and select Run as Administrator. A blue screen with white writing should open up – if this screen doesn’t say “Administrator: ” at the top, the 2nd command below will likely fail.

Type the following followed by Enter:

Get-NetConnectionProfile

Find the line that says InterfaceIndex and make note of the number. If you have multiple networks you may have to change more than one.

Now type the following, but modify the number to match the InterfaceIndex you want to modify, then hit enter:

Set-NetConnectionProfile -InterfaceIndex 7 -NetworkCategory Private

At minimum this should get this network setting resolved! If this didn’t solve your actual problem, check your firewall settings and your security software!

PowerShell Script Ping and Reverse Lookup Tools

Over the years I have written quite a few scripts many of which are still useful today. I’m a big fan of PowerShell as I frequently run into Windows environments.

These Ping and Reverse (DNS) Lookup Scripts have come in handy for me. They will process a list of hostnames or IPs in a text file and then export the outputs to a .csv or a formatted Excel (.xls) workbook. Additional details are in the comments of the code. Enjoy!

PingAndLookupTools on GitHub

–Mike

Auto Copy CD’s, DVD’s, & Optical Media To Disk

Some time ago I decided to backup (to disk) and eliminate my massive optical media collection, but there just wasn’t any good software out there that would copy discs quickly and in a somewhat automated fashion with a single optical drive setup. I wrote the PowerShell script at the end of this post to copy discs with RoboCopy quickly and efficiently. You will need to adjust some of the settings in the USER VARIABLES section such as which drive to monitor, time to run, etc. After the “User Vars” match your config, run the script. It will wait for a disc to be inserted, immediately begin copying to your specified location, then once the disc has been copied, the drive will eject the disc (if it can.) Pull that disc out, insert a new one, and the process will repeat for as long as you have specified!

Prerequisites:

  1. Run on a Windows machine with PowerShell installed, patched, and updated correctly
  2. Have robocopy in your path. Download and install this if you haven’t already. A recommended version is currently available on my site here.
    1. PowerShell’s ExecutionPolicy is set correctly
    2. Run: “Get-ExecutionPolicy” to get the current policy. Likely will be set to Restricted
    3. Run: “Set-ExecutionPolicy RemoteSigned”
    4. Select Yes with the Pop-up prompt
    5. If that doesn’t work…
      1. Run: “Set-ExecutionPolicy -ExecutionPolicy Unrestricted”
        Please research and understand the implications and potential security risks by running in this mode.
  3. I also recommend having PowerGUI Script Editor installed and running (note Dell owns PowerGUI now…)
    1. http://en.community.dell.com/techcenter/powergui/m/bits/20439049
  4. You can Download the Script Here.

Happy copying!
–Mike