0

If remote registry is disabled on a PC, is it possible in any way to remotely import a task into task scheduler that starts the service?

I can still manage the PC's VIA AD, and run computer management on them; wondering if this can somehow be used as a workaround through powershell?

Can powershell be used to remotely open Computer management, import a task that enables remote registry?

Thanks all!

1 Answers1

0

I use the following function:

function Start-RemoteRegistryService {
<#
.SYNOPSIS
Starts the Remote Registry service on a remote computer.
.DESCRIPTION
Starts the Remote Registry service on a remote computer. The WinRM service must be running and not blocked by firewall rules, and the person using this cmdlet must have sufficient rights to start and stop services on the remote computer.
.PARAMETER ComputerName
The name of the computer to start the Remote Registry service on.
.INPUTS
ComputerName accepts any object with a member property named ComputerName
.OUTPUTS
[System.Integer]
A zero return indicates successful start of the Remote Registry service on the target computer.
.EXAMPLE
PS C:\> Start-RemoteRegistryService -ComputerName LAB01

Starts the Remote Registry service on computer LAB01
#>
    [CmdletBinding()]

    Param (
        [Parameter(ValueFromPipelineByPropertyName=$true)]
        [String]$ComputerName
    )

    try {
        $RemoteRegistry = Get-CIMInstance -Class Win32_Service -Comp $ComputerName -Filter "Name='RemoteRegistry'"
        if ($RemoteRegistry.State -ne "Running") {
            return Invoke-CIMMethod -InputObject $RemoteRegistry -MethodName StartService
        }
    }
    catch {
        throw
    }
}

(I’d originally planned on better error handling, but I’ve had too much hands on my time...)

The original version used WMI but was almost identical:

function Start-RemoteRegistryService {
<#
.SYNOPSIS
Starts the Remote Registry service on a remote computer.
.DESCRIPTION
Starts the Remote Registry service on a remote computer. The WinRM service must be running and not blocked by firewall rules, and the person using this cmdlet must have sufficient rights to start and stop services on the remote computer.
.PARAMETER ComputerName
The name of the computer to start the Remote Registry service on.
.INPUTS
ComputerName accepts any object with a member property named ComputerName
.OUTPUTS
[System.Integer]
A zero return indicates successful start of the Remote Registry service on the target computer.
.EXAMPLE
PS C:\> Start-RemoteRegistryService -ComputerName LAB01

Starts the Remote Registry service on computer LAB01
#>
    [CmdletBinding()]

    Param (
        [Parameter(ValueFromPipelineByPropertyName=$true)]
        [String]$ComputerName
    )

    try {
        $rrstatus = (Get-Service -ComputerName $ComputerName -Name RemoteRegistry).Status
        if ($rrstatus -ne "Running") {
            if ($ComputerName -eq $env:ComputerName) {
                Start-Service -Name RemoteRegistry
            } else {
                return ((Get-WmiObject -ComputerName $ComputerName -Class Win32_Service -Filter "Name='RemoteRegistry'").StartService()).ReturnValue
            }
        }
    }
    catch {
        throw
    }
}
Jeff Zeitlin
  • 9,773
  • 2
  • 21
  • 33