Restart Service on Remote Computer with PowerShell

If you search for “PowerShell Restart Service Remote Computer”, the challenge is a lot of the top results will be for earlier versions of PowerShell and a lot more complicated than needed. For some reason, Microsoft doesn’t just give the Restart-Service command a -ComputerName switch…I guess that would be too intuitive.   After some digging, I found it’s still easy, you just need to Get-Service first.  Below is an example of restarting BITS.  I used a wildcard just to show you that wildcards work.  Run this from an elevated PowerShell prompt and replace <COMPUTERNAME> with the name of your computers.

Get-Service -Name BIT* -ComputerName  | Restart-Service

This works great for restarting a service on a few remote computers.  If you need to restart a service for all the computers in your domain, here’s a script to help with that process.  This script does need to be run from an AD server as it requires Get-ADComputer or you’ll need to install the PS module on the server where you’ll be running this script.   The value on this is it pulls out all the active computers and restarts you’re selected service.  This helped us on an issue where our remote access software ScreenConnect started dropping out of our console.  A bug in their keep alives is causing the issue and the temp fix is to restart the service…but sometimes it’s hard to remember what’s missing so this goes through all computers active in your domain and restarts the service.

$today = Get-Date
$cutoffdate = $today.AddDays(-15)

Get-ADComputer  -Properties * -Filter {LastLogonDate -gt $cutoffdate}|Select -Expand DNSHostName  | out-file C:\All-Computers.txt

$computers = get-content "C:\All-Computers.txt"
$amount = $computers.count

foreach ($computer in $computers)
   Invoke-Command -ComputerName $computer { Restart-Service -Name 'ScreenConnect Client (f95335af7be34c6f)' } -ErrorAction SilentlyContinue Write-Progress -Activity "Working..." -CurrentOperation "$a Complete of $amount" -Status "Please wait.  Restarting service."


Can’t Change Display Brightness on Windows 10

If after upgrading to Windows 10 you can’t change your display brightness (the option may be missing in Settings/Display), this may be your fix.

  1. Right-Click the Start button and select Device Manager
  2. Expand the Monitors section
  3. Right-click on Generic PnP Monitor and click on Enable

After fighting to find the latest video drivers (HP hasn’t re990leased Win 10 drivers for my Pavilion), this fixed my issue.

Windows 10 Fix for Remote Gateway VPN Bug

When connected to a vpn, we often want to continue to use our connection for Internet traffic rather than forwarding it through the tunnel.  With Win 10, there’s a bug that prevents us from clicking on the Properties button for TCP/IP v4. David Carroll posted a fix here .  Other posts give fixes of editing the RAS phonebook, but David’s PowerShell method is much easier to me.  I’m posting the steps here as well (mostly for my records).  One key, I’ve noticed that if you have a space in the name of your VPN the Get-VpnConnection won’t return your connection info.  So if you have a connection like “VPN 1”, this method wouldn’t work for me but if you name it “VPN1” it works fine.

  1. From PowerShell, type Get-VpnConnection while connected to your VPN.  You’ll notice that the SplitTunneling is set to False.
  2. Set-VpnConnection “VPN1” -SplitTunneling 1 (replace VPN1 with the name of your VPN returned from the Get-VpnConnection.
  3. Disconnect from your VPN session and reconnect.  
  4. In Bing or Google, just type “what is my ip” and you should have your local internet IP rather than the one going through the VPN.

That should do it.

DPM 2012 fails to backup SQL 2012 database

Our SQL 2008 backups were working just fine with Data Protection Manager 2012 until we upgraded SQL to SQL 2012.  Then we started getting the error:

The DPM job failed for SQL Server 2012 database <SQL database> on <our sql server> because the protection agent did not have sysadmin privileges on the SQL Server instance. (ID 33424 Details: )

The suggestion is to add “‘NT Service\DPMRA\ to the sysadmin role on the SQL Server instance.” That’s very specific so that must be the fix.  The problem is I don’t have an ‘NT Service\DPMRA’ user in Windows or SQL.  Here’s the fix:

  1. In SQL Management Studio, connect to the SQL 2012 Server and then expand Security.
  2. Expand Logins and right click on NT AUTHORITY\SYSTEM and select Properties.
  3. Click Server Roles, check sysadmin and click OK.

I read a post saying you could also add NT Service\DPMA like the Recommended Action in DPM states, but I don’t have that as a SQL Logins and wasn’t able to find it as a Windows account to create one.

Once I added sysadmin to the Server Roles, I was able to right click and “Perform Consistency Check…” and everything took off.  You may also go to the jobs themselves and click “Run configuration protection job again”.

Note, for me the Consistency Checks failed on some but this time with a new (more common) error saying “Recovery point creation failed”.  The fix was simply to create a new Recovery Point.

Server 2012 GPO–Hide These Specified Drives

Prior to Server 2012, if you wanted to hide certain drives through GPO you’d edit User ConfigurationPoliciesAdministrative TemplatesWindows Components, and Windows Explorer changing the GPO Hide the specified drives in My Computer as stated in MS KB 231289.

After upgrading our domain to Windows Server 2012, I could not find that setting.  Turns out the Windows Explorer has been renamed to File Explorer  in the GPO. There you’ll find your settings.   🙂

That being said, it’s sort of an old policy and only hides certain drives.  So you may need this blog post to hide other drives.