<?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>powershell | KC's Blog</title>
	<atom:link href="https://www.kjctech.net/tag/powershell/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.kjctech.net</link>
	<description></description>
	<lastBuildDate>Sat, 22 Mar 2025 05:22:34 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://i0.wp.com/www.kjctech.net/wp-content/uploads/2016/12/cropped-KC-Logo.png?fit=32%2C32&#038;ssl=1</url>
	<title>powershell | KC's Blog</title>
	<link>https://www.kjctech.net</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">24634607</site>	<item>
		<title>Remotely Uninstalling A Program Using PowerShell</title>
		<link>https://www.kjctech.net/remotely-uninstalling-a-program-using-powershell/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=remotely-uninstalling-a-program-using-powershell</link>
					<comments>https://www.kjctech.net/remotely-uninstalling-a-program-using-powershell/#respond</comments>
		
		<dc:creator><![CDATA[Kent Chen]]></dc:creator>
		<pubDate>Fri, 15 Mar 2024 06:00:32 +0000</pubDate>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[powershell]]></category>
		<guid isPermaLink="false">https://www.kjctech.net/?p=5144</guid>

					<description><![CDATA[<p>If you don&#8217;t have a software deployment tool, such as PDQ Deployment, uninstalling a program remotely on a computer could be painful. With PowerShell, it could make the process a lot easier. Uninstalling a program via WMI First, let&#8217;s see how to view the installed program. Get-CimInstance -Class Win32_Product -ComputerName $computername To specify which program, you can pipe the result [&#8230;]</p>
The post <a href="https://www.kjctech.net/remotely-uninstalling-a-program-using-powershell/">Remotely Uninstalling A Program Using PowerShell</a> first appeared on <a href="https://www.kjctech.net">KC's Blog</a>.]]></description>
										<content:encoded><![CDATA[<p>If you don&#8217;t have a software deployment tool, such as PDQ Deployment, uninstalling a program remotely on a computer could be painful. With PowerShell, it could make the process a lot easier.</p>



<h3 class="wp-block-heading">Uninstalling a program via WMI</h3>



<p>First, let&#8217;s see how to view the installed program.</p>



<pre class="wp-block-preformatted">Get-CimInstance -Class Win32_Product -ComputerName $computername</pre>



<p>To specify which program, you can pipe the result to Where-Object with a query like this.</p>



<pre class="wp-block-preformatted">Get-CimInstance -Class Win32_Product -ComputerName $computername | Where-Object {$_.Name -Like 'Adobe Acrobat 2017'}</pre>



<p>You can even use the wildcard in this case to find all Adobe-related programs.</p>



<pre class="wp-block-preformatted">Get-CimInstance -Class Win32_Product -ComputerName $computername | Where-Object {$_.Name -Like 'Adobe*'}</pre>



<p>If the output has only one result, you can simply call up the Uninstall() procedure to uninstall the program.</p>



<pre class="wp-block-preformatted">(Get-CimInstance -Class Win32_Product -ComputerName $computername | Where-Object {$_.Name -Like 'Adobe Acrobat 2017'}).uninstall()</pre>



<p>If the output has multiple results, you can use the <strong>ForEach()</strong> method to loop through each app and uninstall it.</p>



<pre class="wp-block-code"><code lang="powershell" class="language-powershell">$apps = Get-CimInstance -Class Win32_Product -ComputerName $computername | Where-Object {$_.Name -Like 'Adobe*'}
ForEach ($app in $apps) {
  $app.uninstall()
}</code></pre>



<h3 class="wp-block-heading">Uninstalling a program via Uninstall-Package</h3>



<p>Not all installed programs can be uninstalled via WMI. If the above method fails, Uninstall-Package would be a good option next in the line. Also, if it&#8217;s a MSI installed program, you have a better chance of uninstalling it this way.</p>



<p>Use the <strong><em>Get-Package</em></strong> cmdlet to find the program and pipe the result to <strong><em>Uninstall-Package</em></strong> to get it uninstalled. The nice thing about this method is that you can uninstall a bunch of related programs in one line.</p>



<pre class="wp-block-preformatted">Get-Package -Name "Kofax*" | Uninstall-Package</pre>



<p>The drawback is that you would need to use the <strong><em>Invoke-Command</em></strong> cmdlet to execute it on a remote computer.</p>



<pre class="wp-block-preformatted">Invoke-Command -ComputerName $computername -Scriptblock {Get-Package -Name 'Kofax*' | Uninstall-Package</pre>



<p></p>The post <a href="https://www.kjctech.net/remotely-uninstalling-a-program-using-powershell/">Remotely Uninstalling A Program Using PowerShell</a> first appeared on <a href="https://www.kjctech.net">KC's Blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://www.kjctech.net/remotely-uninstalling-a-program-using-powershell/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">5144</post-id>	</item>
		<item>
		<title>Deal with Deleted Sites that Can&#8217;t be Permenately Deleted in SharePoint Online</title>
		<link>https://www.kjctech.net/deal-with-deleted-sites-that-cant-be-permenately-deleted-in-sharepoint-online/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=deal-with-deleted-sites-that-cant-be-permenately-deleted-in-sharepoint-online</link>
					<comments>https://www.kjctech.net/deal-with-deleted-sites-that-cant-be-permenately-deleted-in-sharepoint-online/#respond</comments>
		
		<dc:creator><![CDATA[Kent Chen]]></dc:creator>
		<pubDate>Sat, 24 Jun 2023 06:51:44 +0000</pubDate>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[SharePoint Online]]></category>
		<guid isPermaLink="false">https://www.kjctech.net/?p=5091</guid>

					<description><![CDATA[<p>In SharePoint Online, deleted sites will be permanently deleted automatically after a certain period of time so normally you don&#8217;t really need to worry about it. If you need to get rid of them now so you can reuse the URL right away, you can permanently delete them right from Deleted Sites on the SharePoint Online Admin portal. But what [&#8230;]</p>
The post <a href="https://www.kjctech.net/deal-with-deleted-sites-that-cant-be-permenately-deleted-in-sharepoint-online/">Deal with Deleted Sites that Can’t be Permenately Deleted in SharePoint Online</a> first appeared on <a href="https://www.kjctech.net">KC's Blog</a>.]]></description>
										<content:encoded><![CDATA[<p>In SharePoint Online, deleted sites will be permanently deleted automatically after a certain period of time so normally you don&#8217;t really need to worry about it. If you need to get rid of them now so you can reuse the URL right away, you can permanently delete them right from Deleted Sites on the SharePoint Online Admin portal.</p>



<p>But what if the Permanently delete option is greyed out like this?</p>



<figure class="wp-block-image size-large"><img data-recalc-dims="1" fetchpriority="high" decoding="async" width="600" height="283" src="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-5.png?resize=600%2C283&#038;ssl=1" alt="" class="wp-image-5093" srcset="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-5.png?resize=600%2C283&amp;ssl=1 600w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-5.png?resize=450%2C212&amp;ssl=1 450w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-5.png?resize=250%2C118&amp;ssl=1 250w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-5.png?resize=768%2C362&amp;ssl=1 768w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-5.png?resize=700%2C330&amp;ssl=1 700w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-5.png?resize=520%2C245&amp;ssl=1 520w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-5.png?resize=360%2C170&amp;ssl=1 360w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-5.png?resize=100%2C47&amp;ssl=1 100w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-5.png?w=871&amp;ssl=1 871w" sizes="(max-width: 600px) 100vw, 600px" /></figure>



<p>That&#8217;s because the Primary admin of the site is still set as the Group owners. You can&#8217;t purge the sites that still have any connections to the M365 groups. So, you can either restore the site and change the primary owner to an individual user and then delete it again, or better, you can take advantage of the power of PowerShell.</p>



<pre class="wp-block-preformatted">Install-Module -Name Microsoft.Online.SharePoint.PowerShell
Connect-SPOService -Url https://tenent-name.sharepoint.com
Remove-SPODeletedSite -Identity site_url</pre>



<p>It works like a charm, except if you are trying it in PowerShell 7, in which you won&#8217;t be able to connect to the SharePoint Online service. Check out <a href="https://www.kjctech.net/using-sharepoint-online-management-shell-with-powershell-7/" target="_blank" rel="noopener" title="Using SharePoint Online Management Shell with PowerShell 7">this</a> to see how to get around it.</p>The post <a href="https://www.kjctech.net/deal-with-deleted-sites-that-cant-be-permenately-deleted-in-sharepoint-online/">Deal with Deleted Sites that Can’t be Permenately Deleted in SharePoint Online</a> first appeared on <a href="https://www.kjctech.net">KC's Blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://www.kjctech.net/deal-with-deleted-sites-that-cant-be-permenately-deleted-in-sharepoint-online/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">5091</post-id>	</item>
		<item>
		<title>Using SharePoint Online Management Shell with PowerShell 7</title>
		<link>https://www.kjctech.net/using-sharepoint-online-management-shell-with-powershell-7/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-sharepoint-online-management-shell-with-powershell-7</link>
					<comments>https://www.kjctech.net/using-sharepoint-online-management-shell-with-powershell-7/#respond</comments>
		
		<dc:creator><![CDATA[Kent Chen]]></dc:creator>
		<pubDate>Sat, 24 Jun 2023 06:49:34 +0000</pubDate>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[SharePoint Online]]></category>
		<guid isPermaLink="false">https://www.kjctech.net/?p=5096</guid>

					<description><![CDATA[<p>To start using SharePoint Online Management shell, you just need to install the module or import it if you already had it installed, and then start enjoying it. Install-Module -Name Microsoft.Online.SharePoint.PowerShell It works perfectly in PowerShell 5 but failed miserably in PowerShell 7. It throws an error when trying to connect to SharePoint Online. The workaround is to use import [&#8230;]</p>
The post <a href="https://www.kjctech.net/using-sharepoint-online-management-shell-with-powershell-7/">Using SharePoint Online Management Shell with PowerShell 7</a> first appeared on <a href="https://www.kjctech.net">KC's Blog</a>.]]></description>
										<content:encoded><![CDATA[<p>To start using SharePoint Online Management shell, you just need to install the module or import it if you already had it installed, and then start enjoying it.</p>



<pre class="wp-block-preformatted">Install-Module -Name Microsoft.Online.SharePoint.PowerShell</pre>



<figure class="wp-block-image size-large"><a href="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-6.png?ssl=1" data-rel="lightbox-image-0" data-rl_title="" data-rl_caption="" title=""><img data-recalc-dims="1" decoding="async" width="600" height="144" src="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-6.png?resize=600%2C144&#038;ssl=1" alt="" class="wp-image-5097" srcset="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-6.png?resize=600%2C144&amp;ssl=1 600w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-6.png?resize=450%2C108&amp;ssl=1 450w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-6.png?resize=250%2C60&amp;ssl=1 250w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-6.png?resize=768%2C185&amp;ssl=1 768w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-6.png?resize=700%2C168&amp;ssl=1 700w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-6.png?resize=520%2C125&amp;ssl=1 520w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-6.png?resize=360%2C87&amp;ssl=1 360w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-6.png?resize=100%2C24&amp;ssl=1 100w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-6.png?w=981&amp;ssl=1 981w" sizes="(max-width: 600px) 100vw, 600px" /></a></figure>



<p>It works perfectly in PowerShell 5 but failed miserably in PowerShell 7. It throws an error when trying to connect to SharePoint Online.</p>



<figure class="wp-block-image size-large"><a href="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-7.png?ssl=1" data-rel="lightbox-image-1" data-rl_title="" data-rl_caption="" title=""><img data-recalc-dims="1" decoding="async" width="600" height="78" src="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-7.png?resize=600%2C78&#038;ssl=1" alt="" class="wp-image-5098" srcset="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-7.png?resize=600%2C78&amp;ssl=1 600w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-7.png?resize=450%2C58&amp;ssl=1 450w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-7.png?resize=250%2C32&amp;ssl=1 250w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-7.png?resize=520%2C68&amp;ssl=1 520w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-7.png?resize=360%2C47&amp;ssl=1 360w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-7.png?resize=100%2C13&amp;ssl=1 100w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-7.png?w=701&amp;ssl=1 701w" sizes="(max-width: 600px) 100vw, 600px" /></a></figure>



<p>The workaround is to use import the module in a compatible mode.</p>



<pre class="wp-block-preformatted">Import-Module Microsoft.Online.SharePoint.PowerShell -UseWindowsPowerShell</pre>



<p>But if you only have PowerShell 7 or install the module in PowerShell 7, you won&#8217;t be able to import the module in the compatible mode, because no valid module file was found in any module directory.l</p>



<figure class="wp-block-image size-large"><a href="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-8.png?ssl=1" data-rel="lightbox-image-2" data-rl_title="" data-rl_caption="" title=""><img data-recalc-dims="1" loading="lazy" decoding="async" width="600" height="44" src="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-8.png?resize=600%2C44&#038;ssl=1" alt="" class="wp-image-5099" srcset="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-8.png?resize=600%2C44&amp;ssl=1 600w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-8.png?resize=450%2C33&amp;ssl=1 450w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-8.png?resize=250%2C18&amp;ssl=1 250w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-8.png?resize=768%2C56&amp;ssl=1 768w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-8.png?resize=700%2C51&amp;ssl=1 700w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-8.png?resize=520%2C38&amp;ssl=1 520w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-8.png?resize=360%2C26&amp;ssl=1 360w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-8.png?resize=100%2C7&amp;ssl=1 100w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-8.png?w=1096&amp;ssl=1 1096w" sizes="auto, (max-width: 600px) 100vw, 600px" /></a></figure>



<p>You will have to specify the location of the module file to import it. By default, you should be able to locate the installed module from the following location.</p>



<pre class="wp-block-preformatted">%userprofile%\Documents\PowerShell\Modules\</pre>



<p>Then run the following cmdlet and you should be all set.</p>



<pre class="wp-block-preformatted">import-Module "%userprofile%\Documents\PowerShell\Modules\Microsoft.Online.SharePoint.PowerShell\16.0.23710.12000\Microsoft.Online.SharePoint.PowerShell.psd1" -UseWindowsPowerShell</pre>The post <a href="https://www.kjctech.net/using-sharepoint-online-management-shell-with-powershell-7/">Using SharePoint Online Management Shell with PowerShell 7</a> first appeared on <a href="https://www.kjctech.net">KC's Blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://www.kjctech.net/using-sharepoint-online-management-shell-with-powershell-7/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">5096</post-id>	</item>
		<item>
		<title>Encrypting Disks with BitLocker in PowerShell</title>
		<link>https://www.kjctech.net/encrypting-disks-with-bitlocker-in-powershell/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=encrypting-disks-with-bitlocker-in-powershell</link>
					<comments>https://www.kjctech.net/encrypting-disks-with-bitlocker-in-powershell/#respond</comments>
		
		<dc:creator><![CDATA[Kent Chen]]></dc:creator>
		<pubDate>Fri, 23 Jun 2023 00:22:52 +0000</pubDate>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[BitLocker]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[powershell]]></category>
		<guid isPermaLink="false">https://www.kjctech.net/?p=5085</guid>

					<description><![CDATA[<p>When I need to turn on BitLocker on either a system drive or an external USB drive, I usually just right-click the drive, choose Turn on BitLocker, and then follow the wizard. It works pretty well and does what I need. What I didn&#8217;t know is that there are a lot more options you can choose from when you do [&#8230;]</p>
The post <a href="https://www.kjctech.net/encrypting-disks-with-bitlocker-in-powershell/">Encrypting Disks with BitLocker in PowerShell</a> first appeared on <a href="https://www.kjctech.net">KC's Blog</a>.]]></description>
										<content:encoded><![CDATA[<p>When I need to turn on BitLocker on either a system drive or an external USB drive, I usually just right-click the drive, choose Turn on BitLocker, and then follow the wizard. It works pretty well and does what I need. What I didn&#8217;t know is that there are a lot more options you can choose from when you do so using PowerShell.</p>



<p>For example, there is more than just one encryption method you can use. With -EncryptionMethod, you can specify one of 4 methods to encrypt your drive, AES128, AES258, XtsAes128, or XtsAes256.</p>



<pre class="wp-block-preformatted">Enable-BitLocker -MountPoint "c:" -EncryptionMethod Aes256 -RecoveryKeyPath "E:\Recovery\" -RecoveryKeyProtector</pre>



<p>You can also enable BitLocker with a specified AD user account so that when a user accesses the encrypted drive, they will get prompted for credentials for that account.</p>



<pre class="wp-block-preformatted">Enable-BitLocker -MountPoint "C:" -EncryptionMethod Aes128 -AdAccountOrGroup "Western\SarahJones" -AdAccountOrGroupProtector</pre>



<p>Have you ever wondered what is wrong with my BitLocker drive that has a warning sign?</p>



<figure class="wp-block-image size-full"><img data-recalc-dims="1" loading="lazy" decoding="async" width="306" height="101" src="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image.png?resize=306%2C101&#038;ssl=1" alt="" class="wp-image-5086" srcset="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image.png?w=306&amp;ssl=1 306w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image.png?resize=250%2C83&amp;ssl=1 250w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image.png?resize=100%2C33&amp;ssl=1 100w" sizes="auto, (max-width: 306px) 100vw, 306px" /></figure>



<p><strong><em>Get-BitLockerVolume</em></strong> tells you everything.</p>



<figure class="wp-block-image size-large"><a href="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-1.png?ssl=1" data-rel="lightbox-image-0" data-rl_title="" data-rl_caption="" title=""><img data-recalc-dims="1" loading="lazy" decoding="async" width="600" height="107" src="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-1.png?resize=600%2C107&#038;ssl=1" alt="" class="wp-image-5087" srcset="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-1.png?resize=600%2C107&amp;ssl=1 600w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-1.png?resize=450%2C80&amp;ssl=1 450w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-1.png?resize=250%2C45&amp;ssl=1 250w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-1.png?resize=768%2C137&amp;ssl=1 768w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-1.png?resize=700%2C125&amp;ssl=1 700w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-1.png?resize=520%2C93&amp;ssl=1 520w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-1.png?resize=360%2C64&amp;ssl=1 360w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-1.png?resize=100%2C18&amp;ssl=1 100w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-1.png?w=819&amp;ssl=1 819w" sizes="auto, (max-width: 600px) 100vw, 600px" /></a></figure>



<p>Aha&#8230;it&#8217;s because the Protection is off. Let&#8217;s Resume-BitLocker it.</p>



<figure class="wp-block-image size-large"><img data-recalc-dims="1" loading="lazy" decoding="async" width="600" height="169" src="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-2.png?resize=600%2C169&#038;ssl=1" alt="" class="wp-image-5088" srcset="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-2.png?resize=600%2C169&amp;ssl=1 600w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-2.png?resize=450%2C127&amp;ssl=1 450w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-2.png?resize=250%2C71&amp;ssl=1 250w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-2.png?resize=768%2C217&amp;ssl=1 768w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-2.png?resize=700%2C198&amp;ssl=1 700w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-2.png?resize=520%2C147&amp;ssl=1 520w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-2.png?resize=360%2C102&amp;ssl=1 360w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-2.png?resize=100%2C28&amp;ssl=1 100w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-2.png?w=829&amp;ssl=1 829w" sizes="auto, (max-width: 600px) 100vw, 600px" /></figure>



<p>What&#8217;s my encrypted system drive&#8217;s recovery password?</p>



<pre class="wp-block-preformatted">(Get-bitlockervolume -MountPoint "C:").KeyProtector</pre>



<p>Can I save it to Active Directory so I don&#8217;t have to keep the file? Sure thing.</p>



<pre class="wp-block-preformatted">Backup-BitLockerKeyProtector -MountPoint "C" -KeyProtectorId (Get-bitlockervolume -MountPoint "C:").KeyProtector[1].KeyProtectorId</pre>



<p>But whoops, it says &#8220;Group Policy does not permit the storage of recovery information to Active Directory&#8221;. What to do?</p>



<p>There are two policies you will need to change here. Open the policy assigned to the GPO, and go to the following location.</p>



<pre class="wp-block-preformatted">Computer Configuration &gt; Policies &gt; Administrative Templates &gt; Windows Components &gt; BitLocker Drive Encryption</pre>



<p>And enable the policy called <strong><em>Store BitLocker Recovery information in Active Directory Domain Services</em></strong></p>



<p>Then go to one of the following sub-locations of BitLocker Drive Encryption, whichever one you would be using.</p>



<ul class="wp-block-list">
<li>Fixed Data Drives</li>



<li>Operating System Drives</li>



<li>Removable Data Drives</li>
</ul>



<figure class="wp-block-image size-full"><img data-recalc-dims="1" loading="lazy" decoding="async" width="357" height="123" src="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-3.png?resize=357%2C123&#038;ssl=1" alt="" class="wp-image-5089" srcset="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-3.png?w=357&amp;ssl=1 357w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-3.png?resize=250%2C86&amp;ssl=1 250w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2023/06/image-3.png?resize=100%2C34&amp;ssl=1 100w" sizes="auto, (max-width: 357px) 100vw, 357px" /></figure>



<p>And enable the policy called <strong><em>Choose how BitLocker-protected operating system drives can be recovered</em>.</strong></p>



<p>If it still doesn&#8217;t work, you may have to install the BitLocker management tools on the AD server.</p>



<pre class="wp-block-preformatted">Install-WindowsFeature BitLocker -IncludeAllSubFeature -IncludeManagementTools</pre>



<p>With GPO configured to save the BitLocker keys to AD, we can enable BitLocker and save the keys directly to AD in PowerShell.</p>



<pre class="wp-block-preformatted">Add-BitLockerKeyProtector -MountPoint C: -RecoveryPasswordProtector | Out-Null<br>Enable-BitLocker -MountPoint C: -TpmProtector -EncryptionMethod Aes256 -SkipHardwareTest</pre>The post <a href="https://www.kjctech.net/encrypting-disks-with-bitlocker-in-powershell/">Encrypting Disks with BitLocker in PowerShell</a> first appeared on <a href="https://www.kjctech.net">KC's Blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://www.kjctech.net/encrypting-disks-with-bitlocker-in-powershell/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">5085</post-id>	</item>
		<item>
		<title>Retrieving Logon/Logoff Activities from A Remote Domain-Joined Computer</title>
		<link>https://www.kjctech.net/retrieving-logon-logoff-activities-from-a-remote-domain-joined-computer/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=retrieving-logon-logoff-activities-from-a-remote-domain-joined-computer</link>
					<comments>https://www.kjctech.net/retrieving-logon-logoff-activities-from-a-remote-domain-joined-computer/#respond</comments>
		
		<dc:creator><![CDATA[Kent Chen]]></dc:creator>
		<pubDate>Tue, 23 May 2023 05:44:49 +0000</pubDate>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[powershell]]></category>
		<guid isPermaLink="false">https://www.kjctech.net/?p=5071</guid>

					<description><![CDATA[<p>If you are in an AD environment, checking out the logon activities on certain users can be done through the Security log on the domain controller. However, reading through these log entries can be time-consuming. The workaround is to retrieve the logon activities right from the desktop computer if you know which computer to look to. It&#8217;s actually way easier. [&#8230;]</p>
The post <a href="https://www.kjctech.net/retrieving-logon-logoff-activities-from-a-remote-domain-joined-computer/">Retrieving Logon/Logoff Activities from A Remote Domain-Joined Computer</a> first appeared on <a href="https://www.kjctech.net">KC's Blog</a>.]]></description>
										<content:encoded><![CDATA[<p>If you are in an AD environment, checking out the logon activities on certain users can be done through the Security log on the domain controller. However, reading through these log entries can be time-consuming. The workaround is to retrieve the logon activities right from the desktop computer if you know which computer to look to.</p>



<p>It&#8217;s actually way easier. To retrieve the logon activities from a remote computer for the past 7 days, all you need is to run this.</p>



<pre class="wp-block-preformatted">Get-EventLog System -Source Microsoft-Windows-WinLogon -After (Get-Date).AddDays(-7) -ComputerName $computer</pre>



<p>However, in order to pull the event log from a remote computer, the Remote Registry service needs to be running on that computer. It&#8217;s disabled by default for security reasons.</p>



<p>You will need to reenable the service and start it before pulling the log entries.</p>



<pre class="wp-block-code"><code lang="powershell" class="language-powershell">Invoke-Command -ComputerName $computer -ScriptBlock {
    $service = 'RemoteRegistry'
    Set-Service -Name $service -StartupType Manual
    Start-Service -Name $service
}</code></pre>



<p>Once done, you will need to stop and disable it too.</p>



<pre class="wp-block-code"><code lang="powershell" class="language-powershell">Invoke-Command -ComputerName $computer -ScriptBlock {
    $service = 'RemoteRegistry'
    Stop-Service -Name $service
    Set-Service -Name $service -StartupType Disabled
}</code></pre>



<p>So, putting everything all together,</p>



<pre class="wp-block-code"><code lang="powershell" class="language-powershell">$computer = Read-Host "Coomputer Name:"
Invoke-Command -ComputerName $computer -ScriptBlock {
    $service = 'RemoteRegistry'
    Set-Service -Name $service -StartupType Manual
    Start-Service -Name $service
}
$logs = Get-EventLog System -Source Microsoft-Windows-WinLogon -After (Get-Date).AddDays(-7) -ComputerName $computer
ForEach ($log in $logs){
    $user = Get-ADUser -Filter * | Where-Object {$_.SID -eq $log.ReplacementStrings[1]}
    $log.TimeGenerated.ToString() + ' - ' + $user.Name + ' - ' + $log.Message
}
Invoke-Command -ComputerName $computer -ScriptBlock {
    $service = 'RemoteRegistry'
    Stop-Service -Name $service
    Set-Service -Name $service -StartupType Disabled
}</code></pre>



<p>Bonus point, I&#8217;ve formatted the output with a real username as well.</p>The post <a href="https://www.kjctech.net/retrieving-logon-logoff-activities-from-a-remote-domain-joined-computer/">Retrieving Logon/Logoff Activities from A Remote Domain-Joined Computer</a> first appeared on <a href="https://www.kjctech.net">KC's Blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://www.kjctech.net/retrieving-logon-logoff-activities-from-a-remote-domain-joined-computer/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">5071</post-id>	</item>
		<item>
		<title>How To Monitor A Folder For Any Changes in PowerShell</title>
		<link>https://www.kjctech.net/how-to-monitor-a-folder-for-any-changes-in-powershell/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-monitor-a-folder-for-any-changes-in-powershell</link>
					<comments>https://www.kjctech.net/how-to-monitor-a-folder-for-any-changes-in-powershell/#comments</comments>
		
		<dc:creator><![CDATA[Kent Chen]]></dc:creator>
		<pubDate>Sat, 21 May 2022 06:57:26 +0000</pubDate>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[powershell]]></category>
		<guid isPermaLink="false">https://www.kjctech.net/?p=4748</guid>

					<description><![CDATA[<p>There might be a lot of tools out there that you can use to monitor a specific folder for any changes. But if it can be done in PowerShell, it could make things easier and more flexible. You can do all sorts of things when a change is being made to the folder, such as send an email notification or [&#8230;]</p>
The post <a href="https://www.kjctech.net/how-to-monitor-a-folder-for-any-changes-in-powershell/">How To Monitor A Folder For Any Changes in PowerShell</a> first appeared on <a href="https://www.kjctech.net">KC's Blog</a>.]]></description>
										<content:encoded><![CDATA[<p>There might be a lot of tools out there that you can use to monitor a specific folder for any changes. But if it can be done in PowerShell, it could make things easier and more flexible. You can do all sorts of things when a change is being made to the folder, such as send an email notification or write an entry to log the change to the event log, etc.</p>



<p>To make it happen, we will need help from a Windows .Net class called <em>FileSystemWatcher</em> in System.IO namespace.</p>



<p>The following code, when running, monitors the ID folder and will print the newly changed document before writing an entry to a log file when it detects any changes to the folder.</p>



<pre class="wp-block-code"><code lang="powershell" class="language-powershell">$log = "$home\Desktop\Log.txt"
$pathtomonitor = "X:\ID"
$timeout = 1000

try {
$FileSystemWatcher = New-Object System.IO.FileSystemWatcher $pathtomonitor
$FileSystemWatcher.IncludeSubdirectories = $true

Write-Host "Monitoring content of $PathToMonitor"
while ($true) {
  $change = $FileSystemWatcher.WaitForChanged('All', $timeout)
  if ($change.TimedOut -eq $false)
  {
      # get information about the changes detected
      Write-Host "Change detected:"
      # invoke some actions here when change detected
      if (!($change.ChangeType -eq 'Deleted')){
          Start-Process $change.name -WorkingDirectory $pathtomonitor -verb PrintTo '\\printerserver\printer1' -PassThru | %{ sleep 10;$_ } | kill
      }
      $change | Out-Default
      (Get-Date).ToString() + ", " + $change.ChangeType.ToString() + ", " + $change.Name | Out-File $log -Append
   }
  else
  {
      Write-Host "." -NoNewline
  }
 }
}
finally{
  $FileSystemWatcher.Dispose()
  Write-Host "My Watcher is done."
}</code></pre>



<p>The monitor happens in an endless loop so to abord the monitoring process, you will have to press ctrl+c to break it. And because of that, you will need the <em><strong>try&#8230;finally {}</strong></em> to clean up the mess. When ctrl+c occurs, the code in <em><strong>finally{}</strong></em> will be executed, in which the FileSystemWatcher object can be properly disposed of.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="557" height="229" src="//i0.wp.com/kjctech.net/wp-content/uploads/2022/05/image-2.png" alt="" class="wp-image-4749" srcset="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/05/image-2.png?w=557&amp;ssl=1 557w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/05/image-2.png?resize=450%2C185&amp;ssl=1 450w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/05/image-2.png?resize=250%2C103&amp;ssl=1 250w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/05/image-2.png?resize=520%2C214&amp;ssl=1 520w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/05/image-2.png?resize=360%2C148&amp;ssl=1 360w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/05/image-2.png?resize=100%2C41&amp;ssl=1 100w" sizes="auto, (max-width: 557px) 100vw, 557px" /></figure>



<p>The drawback of this approach is that it monitors folder synchronously so if multiple changes are made simultaneously, only the first one will be recorded. If you don&#8217;t anticipate multiple changes to the folder, this would be perfect. But if not, check <a href="https://community.idera.com/database-tools/powershell/powertips/b/tips/posts/using-filesystemwatcher-correctly-part-2" target="_blank" rel="noreferrer noopener" title="this one">this one</a> out.</p>The post <a href="https://www.kjctech.net/how-to-monitor-a-folder-for-any-changes-in-powershell/">How To Monitor A Folder For Any Changes in PowerShell</a> first appeared on <a href="https://www.kjctech.net">KC's Blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://www.kjctech.net/how-to-monitor-a-folder-for-any-changes-in-powershell/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">4748</post-id>	</item>
		<item>
		<title>Checking Why A Remote Computer is Shutdown or Restarted</title>
		<link>https://www.kjctech.net/checking-why-a-remote-computer-is-shutdown-or-restarted/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=checking-why-a-remote-computer-is-shutdown-or-restarted</link>
					<comments>https://www.kjctech.net/checking-why-a-remote-computer-is-shutdown-or-restarted/#respond</comments>
		
		<dc:creator><![CDATA[Kent Chen]]></dc:creator>
		<pubDate>Tue, 03 May 2022 05:06:04 +0000</pubDate>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[event log]]></category>
		<category><![CDATA[powershell]]></category>
		<guid isPermaLink="false">https://www.kjctech.net/?p=4738</guid>

					<description><![CDATA[<p>For Windows computers, every shutdown or restart is logged in the Event Viewer so you know what exactly happened, whether it&#8217;s a system triggered reboot, or by a user specifically, or a restart because of a system or application crash. So, if you want to dig into this information, all you need is to open Event Viewer, head into System [&#8230;]</p>
The post <a href="https://www.kjctech.net/checking-why-a-remote-computer-is-shutdown-or-restarted/">Checking Why A Remote Computer is Shutdown or Restarted</a> first appeared on <a href="https://www.kjctech.net">KC's Blog</a>.]]></description>
										<content:encoded><![CDATA[<p>For Windows computers, every shutdown or restart is logged in the Event Viewer so you know what exactly happened, whether it&#8217;s a system triggered reboot, or by a user specifically, or a restart because of a system or application crash.</p>



<p>So, if you want to dig into this information, all you need is to open Event Viewer, head into System under Windows logs, and filter out these specific event IDs.</p>



<ul class="wp-block-list"><li>Event ID 41 &#8211; indicating that the computer rebooted without shutting down completely.</li><li>Event ID 1074 &#8211; indicating that a reboot was triggered by an application, including when a user restarted or shut down their computer from the Start Menu or by using Ctrl + Alt + Del.</li><li>Event ID 1076 &#8211; records the reason why the computer was shut down or restarted. It&#8217;s recorded by the first user with shutdown privilege who logs on to the computer after an unexpected restart.</li><li>Event ID 6006 &#8211; indicating whether the computer shuts down correctly.</li><li>Event ID 6008 &#8211; indicating whether the computer shuts down abnormally or unexpectedly.</li></ul>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="600" height="395" src="//i0.wp.com/kjctech.net/wp-content/uploads/2022/05/image-600x395.png" alt="" class="wp-image-4741" srcset="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/05/image.png?resize=600%2C395&amp;ssl=1 600w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/05/image.png?resize=450%2C297&amp;ssl=1 450w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/05/image.png?resize=250%2C165&amp;ssl=1 250w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/05/image.png?resize=520%2C343&amp;ssl=1 520w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/05/image.png?resize=360%2C237&amp;ssl=1 360w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/05/image.png?resize=100%2C66&amp;ssl=1 100w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/05/image.png?w=622&amp;ssl=1 622w" sizes="auto, (max-width: 600px) 100vw, 600px" /></figure>



<p>But I am not going to lie, it&#8217;s quite the work to dig out this information, especially on a remote computer. This is another place where PowerShell really shines in its own way.</p>



<p><strong>Get-EventLog</strong> is the cmdlet that pulls event logs not only from your local computer but remote computers on the same network as well.</p>



<p>To pull the system log from a remote computer called Backup,</p>



<pre class="wp-block-preformatted">Get-EventLog -LogName System -ComputerName Backup</pre>



<p>The list might be too long. So let&#8217;s only pull the logs after Jan 1, 2022.</p>



<pre class="wp-block-preformatted">Get-EventLog -LogName System -ComputerName Backup -After "2022/01/01"</pre>



<p>Now here comes the tricky part, how do I find out these specific events based on the above Event IDs? There are no options to filter out directly so we need to pipe the result through.</p>



<pre class="wp-block-preformatted">Get-EventLog -LogName System -ComputerName Backup -After "2022/01/01" | Where-Object {$_.EventID -in (1074,1076,6006,6008)}</pre>



<p>One more thing, let&#8217;s format the output a bit to show the full event message without being cut off.</p>



<pre class="wp-block-preformatted">Get-EventLog -LogName System -ComputerName Backup -After "2022/01/01" | Where-Object {$_.EventID -in (1074,1076,6006,6008)} | Format-Table TimeGenerated, EventID, Message -Wrap</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="600" height="162" src="//i0.wp.com/kjctech.net/wp-content/uploads/2022/05/image-1-600x162.png" alt="" class="wp-image-4743" srcset="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/05/image-1.png?resize=600%2C162&amp;ssl=1 600w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/05/image-1.png?resize=450%2C121&amp;ssl=1 450w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/05/image-1.png?resize=250%2C67&amp;ssl=1 250w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/05/image-1.png?resize=768%2C207&amp;ssl=1 768w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/05/image-1.png?resize=700%2C189&amp;ssl=1 700w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/05/image-1.png?resize=520%2C140&amp;ssl=1 520w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/05/image-1.png?resize=360%2C97&amp;ssl=1 360w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/05/image-1.png?resize=100%2C27&amp;ssl=1 100w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/05/image-1.png?w=1115&amp;ssl=1 1115w" sizes="auto, (max-width: 600px) 100vw, 600px" /></figure>The post <a href="https://www.kjctech.net/checking-why-a-remote-computer-is-shutdown-or-restarted/">Checking Why A Remote Computer is Shutdown or Restarted</a> first appeared on <a href="https://www.kjctech.net">KC's Blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://www.kjctech.net/checking-why-a-remote-computer-is-shutdown-or-restarted/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">4738</post-id>	</item>
		<item>
		<title>Microsoft 365 Preventing Distribution Group from Receiving Outside Emails</title>
		<link>https://www.kjctech.net/microsoft-365-preventing-distribution-group-from-receiving-outside-emails/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=microsoft-365-preventing-distribution-group-from-receiving-outside-emails</link>
					<comments>https://www.kjctech.net/microsoft-365-preventing-distribution-group-from-receiving-outside-emails/#respond</comments>
		
		<dc:creator><![CDATA[Kent Chen]]></dc:creator>
		<pubDate>Thu, 13 Jan 2022 06:59:34 +0000</pubDate>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Microsoft 365]]></category>
		<category><![CDATA[powershell]]></category>
		<guid isPermaLink="false">https://www.kjctech.net/?p=4706</guid>

					<description><![CDATA[<p>After getting too many spam emails sent to the distribution group, it&#8217;s time to tighten things a bit and restrict these groups from getting emails from outside parties. For regular Microsoft 365 groups, you can simply go to the Exchange Dashboard, open the group, switch to the Settings tab, and uncheck the option &#8220;Allow external senders to email this group&#8220;. [&#8230;]</p>
The post <a href="https://www.kjctech.net/microsoft-365-preventing-distribution-group-from-receiving-outside-emails/">Microsoft 365 Preventing Distribution Group from Receiving Outside Emails</a> first appeared on <a href="https://www.kjctech.net">KC's Blog</a>.]]></description>
										<content:encoded><![CDATA[<p>After getting too many spam emails sent to the distribution group, it&#8217;s time to tighten things a bit and restrict these groups from getting emails from outside parties.</p>



<p>For regular Microsoft 365 groups, you can simply go to the Exchange Dashboard, open the group, switch to the <strong>Settings</strong> tab, and uncheck the option &#8220;<strong>Allow external senders to email this group</strong>&#8220;.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="517" height="353" src="//i0.wp.com/kjctech.net/wp-content/uploads/2022/01/image-2.png" alt="" class="wp-image-4707" srcset="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/01/image-2.png?w=517&amp;ssl=1 517w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/01/image-2.png?resize=450%2C307&amp;ssl=1 450w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/01/image-2.png?resize=250%2C171&amp;ssl=1 250w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/01/image-2.png?resize=360%2C246&amp;ssl=1 360w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/01/image-2.png?resize=100%2C68&amp;ssl=1 100w" sizes="auto, (max-width: 517px) 100vw, 517px" /></figure>



<p>To make these changes in PowerShell, </p>



<pre class="wp-block-preformatted">Set-UnifiedGroup -Identify $group -RequireSenderAuthenticationEnabled $true</pre>



<p>That won&#8217;t work if these groups are synced from an on-premise Active Directory. In that case, you will need to set the <strong>msExchRequireAuthToSendTo</strong> attribute to <strong>True</strong> in AD&#8217;s group properties.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="400" height="473" src="//i0.wp.com/kjctech.net/wp-content/uploads/2022/01/image-3.png" alt="" class="wp-image-4708" srcset="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/01/image-3.png?w=400&amp;ssl=1 400w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/01/image-3.png?resize=250%2C296&amp;ssl=1 250w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/01/image-3.png?resize=360%2C426&amp;ssl=1 360w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/01/image-3.png?resize=100%2C118&amp;ssl=1 100w" sizes="auto, (max-width: 400px) 100vw, 400px" /></figure>



<p>And if you have many to update, the following PowerShell script can lend a hand.</p>



<pre class="wp-block-code"><code lang="powershell" class="language-powershell">$groups = Get-ADGroup -Filter * -SearchBase "OU=Groups,DC=TestDomain,DC=Local"
$newvalue = $true

ForEach ($group in $groups){
    $groupinfo = [ADSI]"LDAP://$($user.DistinguishedName)"
    $groupinfo.put('msExchRequireAuthToSendTo', $newvalue)
    $groupinfo.setinfo()
    $group.name + ' ' + $groupinfo.msExchRequireAuthToSendTo
}
</code></pre>The post <a href="https://www.kjctech.net/microsoft-365-preventing-distribution-group-from-receiving-outside-emails/">Microsoft 365 Preventing Distribution Group from Receiving Outside Emails</a> first appeared on <a href="https://www.kjctech.net">KC's Blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://www.kjctech.net/microsoft-365-preventing-distribution-group-from-receiving-outside-emails/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">4706</post-id>	</item>
		<item>
		<title>Active Directory Tip: How To Batch Update Remote Desktop Services Profile Path Property</title>
		<link>https://www.kjctech.net/active-directory-tip-how-to-batch-update-remote-desktop-services-profile-path-property/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=active-directory-tip-how-to-batch-update-remote-desktop-services-profile-path-property</link>
					<comments>https://www.kjctech.net/active-directory-tip-how-to-batch-update-remote-desktop-services-profile-path-property/#respond</comments>
		
		<dc:creator><![CDATA[Kent Chen]]></dc:creator>
		<pubDate>Tue, 11 Jan 2022 07:01:21 +0000</pubDate>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[powershell]]></category>
		<guid isPermaLink="false">https://www.kjctech.net/?p=4701</guid>

					<description><![CDATA[<p>It&#8217;s really easy if you need to make changes to the roaming profile path in Active Directory to multiple user accounts. All you need is to highlight them all, right-click and select Properties. But as you can see, it doesn&#8217;t have the Remote Desktop Service Profile tab. So how do you batch update this property to a large number of [&#8230;]</p>
The post <a href="https://www.kjctech.net/active-directory-tip-how-to-batch-update-remote-desktop-services-profile-path-property/">Active Directory Tip: How To Batch Update Remote Desktop Services Profile Path Property</a> first appeared on <a href="https://www.kjctech.net">KC's Blog</a>.]]></description>
										<content:encoded><![CDATA[<p>It&#8217;s really easy if you need to make changes to the roaming profile path in Active Directory to multiple user accounts. All you need is to highlight them all, right-click and select Properties. </p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="400" height="455" src="//i0.wp.com/kjctech.net/wp-content/uploads/2022/01/image-1.png" alt="" class="wp-image-4703" srcset="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/01/image-1.png?w=400&amp;ssl=1 400w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/01/image-1.png?resize=250%2C284&amp;ssl=1 250w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/01/image-1.png?resize=360%2C410&amp;ssl=1 360w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2022/01/image-1.png?resize=100%2C114&amp;ssl=1 100w" sizes="auto, (max-width: 400px) 100vw, 400px" /></figure>



<p>But as you can see, it doesn&#8217;t have the Remote Desktop Service Profile tab. So how do you batch update this property to a large number of users when needed?</p>



<p>Here is a quick example of using PowerShell to find all users that belong to a specific OU and update them with the new network path for remote desktop service profiles.</p>



<pre class="wp-block-code"><code lang="powershell" class="language-powershell">$users = Get-ADuser -Filter * -SearchBase "OU=Test, DC=Test, DC=LOCAL"
$newpath = ''

ForEach ($user in $users){
    $userinfo = [ADSI]"LDAP://$($user.DistinguishedName)"
    $userinfo.psbase.invokeset('TerminalServicesProfilePath', $newpath)
    $userinfo.setinfo()
    $user.name + ' ' + $userinfo.TerminalServicesProfilePath
}</code></pre>



<p>Enjoy.</p>The post <a href="https://www.kjctech.net/active-directory-tip-how-to-batch-update-remote-desktop-services-profile-path-property/">Active Directory Tip: How To Batch Update Remote Desktop Services Profile Path Property</a> first appeared on <a href="https://www.kjctech.net">KC's Blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://www.kjctech.net/active-directory-tip-how-to-batch-update-remote-desktop-services-profile-path-property/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">4701</post-id>	</item>
		<item>
		<title>What to Do When Network Shared Printer Shown As Printer Model Number</title>
		<link>https://www.kjctech.net/what-to-do-when-network-shared-printer-shown-as-printer-model-number/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=what-to-do-when-network-shared-printer-shown-as-printer-model-number</link>
					<comments>https://www.kjctech.net/what-to-do-when-network-shared-printer-shown-as-printer-model-number/#respond</comments>
		
		<dc:creator><![CDATA[Kent Chen]]></dc:creator>
		<pubDate>Thu, 08 Apr 2021 06:13:46 +0000</pubDate>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[Printer]]></category>
		<category><![CDATA[Windows 10]]></category>
		<guid isPermaLink="false">https://www.kjctech.net/?p=4598</guid>

					<description><![CDATA[<p>I have Ricoh network printers shared from Windows 2012 R2 Server on Windows 10 computers. All went well until recently some of them are shown as Printer Model Number instead. They are still working fine and are shown properly when printing in applications like Microsoft Word. It&#8217;s just annoying. On top of that, on some of the computers, I get [&#8230;]</p>
The post <a href="https://www.kjctech.net/what-to-do-when-network-shared-printer-shown-as-printer-model-number/">What to Do When Network Shared Printer Shown As Printer Model Number</a> first appeared on <a href="https://www.kjctech.net">KC's Blog</a>.]]></description>
										<content:encoded><![CDATA[<p>I have Ricoh network printers shared from Windows 2012 R2 Server on Windows 10 computers. All went well until recently some of them are shown as Printer Model Number instead. They are still working fine and are shown properly when printing in applications like Microsoft Word. It&#8217;s just annoying.</p>



<p>On top of that, on some of the computers, I get nothing when I right-click on them in Devices and Printers.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="349" height="216" src="//i0.wp.com/kjctech.net/wp-content/uploads/2021/04/image.png" alt="" class="wp-image-4599" srcset="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2021/04/image.png?w=349&amp;ssl=1 349w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2021/04/image.png?resize=250%2C155&amp;ssl=1 250w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2021/04/image.png?resize=100%2C62&amp;ssl=1 100w" sizes="auto, (max-width: 349px) 100vw, 349px" /></figure>



<p>And in Settings > Devices > Printers, I see something even worse.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="410" height="242" src="//i0.wp.com/kjctech.net/wp-content/uploads/2021/04/image-1.png" alt="" class="wp-image-4600" srcset="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2021/04/image-1.png?w=410&amp;ssl=1 410w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2021/04/image-1.png?resize=250%2C148&amp;ssl=1 250w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2021/04/image-1.png?resize=360%2C212&amp;ssl=1 360w, https://i0.wp.com/www.kjctech.net/wp-content/uploads/2021/04/image-1.png?resize=100%2C59&amp;ssl=1 100w" sizes="auto, (max-width: 410px) 100vw, 410px" /></figure>



<p>I am still puzzling why it happens and have no idea what the issue is. I&#8217;ve tried to update the printer driver and installed all the updates but nothing helped.</p>



<p>So, I blame bugs caused by Windows Updates. Instead of trying to fix it, I am going to live with it and use PowerShell to manage it when needed.</p>



<p>To list all printers installed on your computer</p>



<pre class="wp-block-preformatted">Get-Printer</pre>



<p>To list all network shared printers installed on your computer.</p>



<pre class="wp-block-preformatted">Get-Printer | Where {$_.Type -eq 'Connection'}</pre>



<p>And if you don&#8217;t want &#8220;Let Windows manage my Default Printers&#8221;, this is to set any network shared printer as default.</p>



<pre class="wp-block-preformatted">(New-Object -Com WScript.Network).SetDefaultPrinter('\\printersever\printername')</pre>



<p>That should be enough, for the time being. But I am still hoping to get the bottom of it, one day.</p>The post <a href="https://www.kjctech.net/what-to-do-when-network-shared-printer-shown-as-printer-model-number/">What to Do When Network Shared Printer Shown As Printer Model Number</a> first appeared on <a href="https://www.kjctech.net">KC's Blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://www.kjctech.net/what-to-do-when-network-shared-printer-shown-as-printer-model-number/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">4598</post-id>	</item>
	</channel>
</rss>
