<br />
<b>Warning</b>:  Constant FORCE_SSL_ADMIN already defined, this will be an error in PHP 9 in <b>/var/www/schmidtpetersen.dk/public_html/wp-config.php</b> on line <b>181</b><br />
<?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 &#8211; Mortens Website</title>
	<atom:link href="https://schmidtpetersen.dk/tag/powershell/feed/" rel="self" type="application/rss+xml" />
	<link>https://schmidtpetersen.dk</link>
	<description>Blog, guides, food and drink recipes and everything in between</description>
	<lastBuildDate>Sat, 16 Jan 2021 00:11:55 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.1</generator>
	<item>
		<title>Get all users from specific Organizational Unit in an Active Directory</title>
		<link>https://schmidtpetersen.dk/2021/01/get-all-users-from-specific-organizational-unit-in-an-active-directory/</link>
					<comments>https://schmidtpetersen.dk/2021/01/get-all-users-from-specific-organizational-unit-in-an-active-directory/#respond</comments>
		
		<dc:creator><![CDATA[Morten]]></dc:creator>
		<pubDate>Sat, 16 Jan 2021 00:10:28 +0000</pubDate>
				<category><![CDATA[Guides]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Organizational Unit]]></category>
		<category><![CDATA[OU]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[User Adminstration]]></category>
		<category><![CDATA[User Export]]></category>
		<category><![CDATA[User Properties]]></category>
		<guid isPermaLink="false">https://schmidtpetersen.dk/?p=127</guid>

					<description><![CDATA[Ever found yourself in need of collection all users in a specific OU, filter for a given set of properties and export the list to a file? If yes, this script is for you! The script will search in domain.domain.tld\Parent-OU\Sub-OU and will select all users in this sub-OU. Here, it will collect the properties SamAccountName, &#8230; <a href="https://schmidtpetersen.dk/2021/01/get-all-users-from-specific-organizational-unit-in-an-active-directory/" class="more-link">Continue reading<span class="screen-reader-text"> "Get all users from specific Organizational Unit in an Active Directory"</span></a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Ever found yourself in need of collection all users in a specific OU, filter for a given set of properties and export the list to a file? If yes, this script is for you!</p>



<pre class="wp-block-code"><code>$Users = Get-ADUser -SearchBase "OU=Sub-OU,OU=Parent-OU,DC=domain,DC=tld" -Filter * -Properties * | Select-Object SamAccountName,DisplayName,GivenName,Surname,whenCreated,Enabled,accountExpires,lastLogonTimestamp,LockedOut
$OUUsers = @()
$OUUsers += "SamAccountName,DisplayName,GivenName,Surname,whenCreated,Enabled,accountExpires,lastLogonTimestamp,LockedOut"
foreach ($User in $Users) {
    if ($User.accountExpires  -eq "9223372036854775807") {
        $OUUsers += "$($User.SamAccountName),$($User.DisplayName),$($User.GivenName),$($User.Surname),$(($User.whenCreated).ToString('yyyy-MM-ddZhh-mm-ss')),$($User.Enabled),$("Never"),$(&#91;datetime]::FromFileTime($User.lastLogonTimestamp).ToString('yyyy-MM-ddZhh-mm-ss')),$($User.LockedOut)"
    }
    if (-not($User.accountExpires  -eq "9223372036854775807")) {
        $OUUsers += "$($User.SamAccountName),$($User.DisplayName),$($User.GivenName),$($User.Surname),$(($User.whenCreated).ToString('yyyy-MM-ddZhh-mm-ss')),$($User.Enabled),$(&#91;datetime]::FromFileTime($User.accountExpires).ToString('yyyy-MM-ddZhh-mm-ss')),$(&#91;datetime]::FromFileTime($User.lastLogonTimestamp).ToString('yyyy-MM-ddZhh-mm-ss')),$($User.LockedOut)"
    }
}
$OUUsers | Out-File C:\tmp\OUUser-Report.csv</code></pre>



<p class="wp-block-paragraph">The script will search in domain.domain.tld\Parent-OU\Sub-OU and will select all users in this sub-OU. Here, it will collect the properties <em>SamAccountName, DisplayName, GivenName, SurName, whenCreated, Enabled, accountExpires, lastLogonTimestamp</em> and <em>LockedOut</em>. These properties will then be exported to the file <em>OUUser-Report.csv</em> which will be stored in <em>C:\tmp</em>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://schmidtpetersen.dk/2021/01/get-all-users-from-specific-organizational-unit-in-an-active-directory/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Corrupted file permissions on Microsoft Windows</title>
		<link>https://schmidtpetersen.dk/2021/01/tilretning-af-filrettigheder-i-windows/</link>
					<comments>https://schmidtpetersen.dk/2021/01/tilretning-af-filrettigheder-i-windows/#respond</comments>
		
		<dc:creator><![CDATA[Morten]]></dc:creator>
		<pubDate>Sun, 10 Jan 2021 15:16:07 +0000</pubDate>
				<category><![CDATA[Guides]]></category>
		<category><![CDATA[cacls]]></category>
		<category><![CDATA[file permissions]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[permissions]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[takeown]]></category>
		<category><![CDATA[Windows]]></category>
		<guid isPermaLink="false">http://schmidtpetersen.dk/?p=34</guid>

					<description><![CDATA[From time to time you might find yourself having troubles with file permissions in a Windows environment. This issue will show itself in you not being able to edit, change, move or delete one or multiple files on your computer. This can happen if the ownership settings of the file(s) are corrupted which happen once &#8230; <a href="https://schmidtpetersen.dk/2021/01/tilretning-af-filrettigheder-i-windows/" class="more-link">Continue reading<span class="screen-reader-text"> "Corrupted file permissions on Microsoft Windows"</span></a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">From time to time you might find yourself having troubles with file permissions in a Windows environment. This issue will show itself in you not being able to edit, change, move or delete one or multiple files on your computer. This can happen if the ownership settings of the file(s) are corrupted which happen once in a while. To recover the file permissions we are going to use two tools native to Windows; <code>takeown</code> and <code>cacls</code>.</p>



<p class="wp-block-paragraph">The way to recover the file permissions are to do the following:</p>



<ol class="wp-block-list"><li>Right-click the <strong>Start button</strong> and press <strong>Windows Powershell (Administrator)</strong></li><li>Execute the command <code>takeown /f &lt;full path to file&gt;</code> e.g., <code>takeown /f C:\Windows\WindowsUpdate.log</code></li><li>This will transfer ownership from whichever user- or system account to the account executing the command. However, ownership does not necessarily grant access to deleting the file.</li><li>To reset this permission set, execute the command <code>cacls &lt;full path to file&gt; /G &lt;Username&gt;:F</code> e.g., <code>cacls C:\Windows\WindowsUpdate.log /G Morten:F</code></li><li>You have now effectively transferred ownership permissions to your account.</li></ol>



<p class="wp-block-paragraph">To read the full list of operators and parameters for the commands, please refer to the official Microsoft documentation for <a rel="noreferrer noopener" href="https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/cacls" data-type="URL" data-id="https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/cacls" target="_blank">cacls</a> and <a rel="noreferrer noopener" href="https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/takeown" data-type="URL" data-id="https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/takeown" target="_blank">takeown</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://schmidtpetersen.dk/2021/01/tilretning-af-filrettigheder-i-windows/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
