<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>shutdown Archives - Jim Dolby</title>
	<atom:link href="https://jim.dolby.id.au/tag/shutdown/feed" rel="self" type="application/rss+xml" />
	<link>https://jim.dolby.id.au/tag/shutdown</link>
	<description>A Geek and still proud of it!</description>
	<lastBuildDate>Sat, 21 Mar 2020 07:23:33 +0000</lastBuildDate>
	<language>en-AU</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
<site xmlns="com-wordpress:feed-additions:1">195341223</site>	<item>
		<title>Remotely Lock &#038; Shutdown computers using PowerShell</title>
		<link>https://jim.dolby.id.au/tips/remotely-lock-shutdown-computers-using-powershell.html</link>
		
		<dc:creator><![CDATA[YTS_Jim]]></dc:creator>
		<pubDate>Sun, 22 Sep 2019 00:18:56 +0000</pubDate>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Windows Tips]]></category>
		<category><![CDATA[lockdown]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[remote]]></category>
		<category><![CDATA[shutdown]]></category>
		<category><![CDATA[Windows 10]]></category>
		<guid isPermaLink="false">https://www.securetech.com.au/?p=191</guid>

					<description><![CDATA[<p>PowerShell takes the functionality of batch scripts to the next level and allows you to Remotely Lock &#38; Shutdown computers using PowerShell. The following needs to be run on each computer if using a workgroup setup. or changed in your AD security policy (to make it permanent – which isn’t advisable without signing the script) [&#8230;]</p>
<p>The post <a href="https://jim.dolby.id.au/tips/remotely-lock-shutdown-computers-using-powershell.html">Remotely Lock &#038; Shutdown computers using PowerShell</a> appeared first on <a href="https://jim.dolby.id.au">Jim Dolby</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p><a href="https://www.securetech.com.au/tag/powershell">PowerShell</a> takes the functionality of batch scripts to the next level and allows you to Remotely Lock &amp; Shutdown computers using PowerShell. </p>



<p>The following needs to be run on each computer if using a workgroup setup. or changed in your AD security policy (to make it permanent – which isn’t advisable without signing the script) </p>



<p><a href="https://www.howtogeek.com/117192/how-to-run-powershell-commands-on-remote-computers/">https://www.howtogeek.com/117192/how-to-run-powershell-commands-on-remote-computers/</a></p>



<pre class="wp-block-code"><code>Enable-PSRemoting
Set-executionpolicy unrestricted
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "192.168.1.250" -Force 
Get-Item WSMan:\localhost\Client\TrustedHosts
Restart-Service WinRM</code></pre>



<p>The above does the following:<br><code>Enable-PSRemoting</code> sets up the policies and firewalls to allow remote connections using powershell<br><code>Set-executionpolicy unrestricted</code> changes the local execution policy to allow execution of all scripts (not just signed)<br><code>Set-Item WSMan:\localhost\Client\TrustedHosts -Value "192.168.1.250" -Force</code> Adds server IP into the trustedhosts to allow execution<br><code>Restart-Service WinRM</code> restarts windows remote management service</p>



<p>We are assuming that your server IP is 192.168.1.250, change as appropriate</p>



<p>Now to the actual shutdown code that will be run from our &#8220;Server&#8221;:</p>



<pre class="wp-block-code"><code>Function Get-MyCredential{
 param(
 [string]$username,
 [string]$password
 )

 $secStr = new-object -typename System.Security.SecureString
 $password.ToCharArray() | ForEach-Object {$secStr.AppendChar($_)}
 return new-object -typename System.Management.Automation.PSCredential -argumentlist $username,$secStr
}
Function Lock-Machine{
 param(
 $machineName
 )

 &amp; winrm set winrm/config/client `@`{TrustedHosts = `"$machineName`"`}
 Invoke-Command -ComputerName $machineName -ScriptBlock { tsdiscon.exe console } -Credential (Get-MyCredential User Pa$W0rd)
 }
Function Hibernate-Machine{
 param(
 $machineName
 )

 &amp; winrm set winrm/config/client `@`{TrustedHosts = `"$machineName`"`}
 Invoke-Command -ComputerName $machineName -ScriptBlock { &amp;"$env:SystemRoot\System32\rundll32.exe" powrprof.dll,SetSuspendState Hibernate } -Credential (Get-MyCredential Administrator password)
}
Lock-Machine "192.168.1.84"
#Lock-Workstation "NameOfTheComputer" (Get-Credential)
Stop-Computer -ComputerName 192.168.1.85 -Force -Credential (Get-MyCredential User Pa$W0rd)</code></pre>



<p></p>
<p>The post <a href="https://jim.dolby.id.au/tips/remotely-lock-shutdown-computers-using-powershell.html">Remotely Lock &#038; Shutdown computers using PowerShell</a> appeared first on <a href="https://jim.dolby.id.au">Jim Dolby</a>.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">191</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Lazy Loading (feed)

Served from: jim.dolby.id.au @ 2026-04-20 22:48:05 by W3 Total Cache
-->