<?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/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>powershell &#8211; WiredPrairie</title>
	<atom:link href="blog/archives/tag/powershell/feed" rel="self" type="application/rss+xml" />
	<link>/blog</link>
	<description>Yet another tech blog.</description>
	<lastBuildDate>Wed, 05 Apr 2017 12:09:38 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.0</generator>
<site xmlns="com-wordpress:feed-additions:1">193486638</site>	<item>
		<title>Automatic Reconnection of iSCSI Targets in Windows 10 using PowerShell</title>
		<link>/blog/index.php/archives/2165</link>
					<comments>/blog/index.php/archives/2165#comments</comments>
		
		<dc:creator><![CDATA[Aaron]]></dc:creator>
		<pubDate>Wed, 05 Apr 2017 00:56:26 +0000</pubDate>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Windows10]]></category>
		<category><![CDATA[certificates]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[windows10]]></category>
		<guid isPermaLink="false">/blog/?p=2165</guid>

					<description><![CDATA[When my highly recommended Synology Disk Station reboots for a required update (I&#8217;ve got it set to automatically reboot), a shared Windows 10 PC in our house cannot always successfully reconnect to the iSCSI targets without manual intervention. Unfortunately, I haven&#8217;t always noticed which has led to several features of Windows not functioning the way [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>When my highly recommended <strong><a href="http://amzn.to/2n932GE">Synology </a>Disk Station</strong> reboots for a required update (I&#8217;ve got it set to automatically reboot), a shared Windows 10 PC in our house cannot always successfully reconnect to the iSCSI targets without manual intervention. Unfortunately, I haven&#8217;t always noticed which has led to several features of Windows not functioning the way I want (I have mapped the iSCSI drives/disks via Windows and made them into network shares for the other PCs/laptops in our house &#8212; this way I can use Windows bitlocker encryption on the iSCSI drive contents).</p>
<p>To make the connection more automatic, I created a simple one line PowerShell script that periodically attempts to connect to any disconnected iSCSI targets using the Windows Task Scheduler.</p>
<p>I saved this into a script file called <strong>reconnect-iscsi-targets.ps1</strong>:</p>
<pre>Get-IscsiTarget | where ($_.isConnected -eq $false) | Connect-IscsiTarget</pre>
<p>Then, in the Task Scheduler, I created a new task set to run every 10 minutes daily. The script just gets all iSCSI targets, filters only those that aren&#8217;t connected, and then passes the results to the connection cmdlet.</p>
<p>For the action, I selected <strong>&#8220;Start a program&#8221;</strong> for program/script, I entered: <strong>&#8220;powershell.exe&#8221;</strong>, and then added the arguments &#8220;<strong>-File</strong>&#8221; and the full path to the file name, like:</p>
<pre>-File c:\Users\aaron\Documents\reconnect-iscsi-targets.ps1</pre>
<p>If there are spaces in the path to the PowerShell file, be sure to add quotes around the full path and file name.</p>
<p><img data-attachment-id="2168" data-permalink="blog/archives/2165/2017-04-04_19-07-23" data-orig-file="blog/wpcontent/uploads/2017/04/2017-04-04_19-07-23.png" data-orig-size="460,500" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Action properties for Task" data-image-description="" data-image-caption="" data-medium-file="blog/wpcontent/uploads/2017/04/2017-04-04_19-07-23-276x300.png" data-large-file="blog/wpcontent/uploads/2017/04/2017-04-04_19-07-23.png" loading="lazy" class="aligncenter wp-image-2168 size-full" src="blog/wpcontent/uploads/2017/04/2017-04-04_19-07-23.png" alt="" width="460" height="500" srcset="blog/wpcontent/uploads/2017/04/2017-04-04_19-07-23.png 460w, /blog/wpcontent/uploads/2017/04/2017-04-04_19-07-23-276x300.png 276w" sizes="(max-width: 460px) 100vw, 460px" /></p>
<p>You shouldn&#8217;t need the <strong>start in</strong> option set (leave it empty if you&#8217;d like).</p>
<p>On the General tab of the task, make sure you&#8217;ve set the &#8220;<strong>Run whether user is logged on or not</strong>&#8221; option and &#8220;<strong>Run with highest privileges</strong>.&#8221;</p>
<p>Next up &#8212; how to quickly<a href="blog/archives/2170"> create a Self-Signed Code-Signing</a> certificate. And, how to actually allow scripts to run!</p>
]]></content:encoded>
					
					<wfw:commentRss>/blog/index.php/archives/2165/feed</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2165</post-id>	</item>
	</channel>
</rss>
