Failed to copy C:\Program Files\Microsoft Configuration Manager\bin\x64\ccmcore.dll to \\DistributionPoint\SMS_DP$\sms\bin\ccmcore.dll. GLE = 32 SCCM 1810

Today I installed the 1810 Upgrade on my SCCM environment. It worked but I had an issue on two distribution-points. The package update failed. I checked in the distmgr.log on the primary site server and had the following error:

Failed to copy C:\Program Files\Microsoft Configuration Manager\bin\x64\ccmcore.dll to \DistributionPoint\SMS_DP$\sms\bin\ccmcore.dll. GLE = 32

And all the package updates are marked as failed on the Distribution-Point.

Here is what I have done to fix it:

I compared the ccmcore.dll on the primary site server with the file on the DP’s with the issue. The version didn’t match so I renamed the file on the distribution points and copied the one from the primary site server to both.

Afterwards you have to wait a few minutes until the next upgrade attemt will be done. For me that fixed the issue. Monitor the progress in the distmgr.log.

Sponsored Post Learn from the experts: Create a successful blog with our brand new courseThe WordPress.com Blog

Are you new to blogging, and do you want step-by-step guidance on how to publish and grow your blog? Learn more about our new Blogging for Beginners course and get 50% off through December 10th.

WordPress.com is excited to announce our newest offering: a course just for beginning bloggers where you’ll learn everything you need to know about blogging from the most trusted experts in the industry. We have helped millions of blogs get up and running, we know what works, and we want you to to know everything we know. This course provides all the fundamental skills and inspiration you need to get your blog started, an interactive community forum, and content updated annually.

Deploy RSAT (Remote Server Administration Tools) for Windows 10 1809 via SCCM – Installer

Beginning with 1809 the installation of the RSAT (Remote Server Administration Tools) changed. It’s no longer a separat download instead it’s now included in “Feature on Demand” and downloads it directly from Microsoft. You can install the features now as optional feature in the settings menu. But in my tests this is buggy and not very user frindly.  I decided to create my own installer based on the Powershell comands. The tool uses Get-WindowsCapability, Add-WindowsCapability and remove-WindowsCapability.

You can deploy the executable via SCCM. As application or package.

The tool looks like below in my Software-Center:

You can select single RSAT Tools or multiple or select all:

Notifications:

Same way to uninstall one or multiple RSAT Tools.

You can find the download here: click

Find Clients with duplicate GUID and duplicate machine SID SCCM

Target: I noticed some computers in SCCM could not install the SCCM client. Once installed on one device another one was dropped out the inventory. The reason is that the SCCM GUID is based on the machine SID. Normally the SID should be unique – but some computers have been cloned without sysprep.

With the two scripts below you can find computers with duplicate machine SID and with the second script you can create a new SCCM GUID for them.

With the following script you can export the machine SID of multiple computers into a CSV file. Change the export path to your needs.

#detect clients with duplicate machine SID

$comp = import-csv C:\users\xxxxx\Desktop\comp.txt

foreach ($computer in $comp.comp)

{

$LocalAccountSID = Get-WmiObject -Query "SELECT SID FROM Win32_UserAccount WHERE LocalAccount = 'True'" -computername $computer | Select-Object -First 1 -ExpandProperty SID

$MachineSID = ($p = $LocalAccountSID -split "-")[0 .. ($p.Length - 2)] -join "-"

$MachineSID = $MachineSID + ";" + "$computer"

$MachineSID >> c:\temp\sid.csv

$MachineSID = $Null

}

 
The import file looks like below. Enter the computer names where you need to check the machine SID.
1

If you find computers with the same SID you can change the SCCM GUID with the following script. No guarantee if this is supported.

$comp = import-csv c:\temp\computer.txt

$password = "password" | ConvertTo-SecureString -asPlainText -Force

$username = "domain\name"

$credential = New-Object System.Management.Automation.PSCredential($username, $password)

foreach ($computer in $comp.comp)

{

#test if WinRM service is running

$test = Test-WSMan -Computer $computer.ToString() -ErrorAction SilentlyContinue

 

if ($test -ne $null)

{

#connection success

Invoke-Command -ComputerName $computer.ToString() -Credential $credential -ScriptBlock {

#stop smsagent host

Stop-Service ccmexec -Force

#remove config

Remove-item c:\windows\SMSCFG.ini -force

#remove sms certs

Remove-Item -Path HKLM:\Software\Microsoft\SystemCertificates\SMS\Certificates\* -Force

#delete certstore sms

certutil –delstore SMS SMS

#start smsagent host

Start-Service ccmexec

}

 

}

#connection failed

else { Write-Warning "$computer cannot connect!" }

}

The import file looks like below. Enter the computer names where you need to change the SCCM GUID.
2

Check Antivirus status Windows Defender or 3rd Party via ConfigMgr SCCM

Target: Get the status of Antivirus Windows Defender or any other 3rd party Antivirus software via “Run a Script” from ConfigMgr into a Log-File.

In the WMI namespace “root\SecurityCenter2” you find the list of installed Antivirus products and their status. I created two scripts to detect the status of Windows Defender and one for Sophos Antivirus. The scripts will show clients where either Windows Defender or Sophos Antivirus is in no clean status or not up to date.

The Scripts converts the product state to an hex-value and outputs the clients with an non-compliant Antivirus into an log file which can be opened with cmtrace.exe or MS Excel.

Windows Defender needs an Hex-Code of 061100 if it’s enabled and up to date.
The following hex-states can occur for Windows Defender:

Windows Defender

060100= disabled and up2date

061110 = enabled and outdated

061100 = enabled and up2date

Sophos Antivirus needs a an Hex-Code of 051000 if it’s enabled and up to date.

Prerequisites: Create a UNC-share and provide everyone full-access in additional modify the NTFS-Permission to provide “Domain Computers” at least write permission on the folder.

Here you can find the script for Windows Defender copy the script and follow the steps below:

The script for Sophos Antivirus is at the end of that blog post.

#currentdate

$CuDate = Get-Date

$CuDate.ToUniversalTime()

#generate random sleep time between 1-10 milliseconds

$rdom= Get-Random -Maximum 10

#logdestination

$destination = "\\servername\sharename$\AvInfo_Defender_SCCM.log"

#get Antivirus

$avWMIres = get-wmiobject -namespace root\SecurityCenter2 -computername localhost -Query "Select * from AntiVirusProduct" | where {$_.Displayname -eq "Windows Defender"}

if ($avWMIres -eq $null)

{

#create the Log and save

Start-Sleep -Milliseconds $rdom

$Log = $env:COMPUTERNAME + "; " + "no Windows Defender found" + "; " + "0" + "; " + $CuDate

$Log | Out-File -FilePath $aFilePath -append -Force

}

else

{

foreach ($av in $avWMIres)

{

#Defender enabled and up to date has a hex state of 061100

#Windows Defender

#(060100) = disabled and u2d

#(061110) = enabled and not u2d

#(061100) = enabled and u2d

$tohex = [Convert]::ToString($av.productState, 16)

#add zero for hex

$tohex = "0" + $tohex

$successavstate = "061100"

#if not good AV is installed -> add to LOG

If ($tohex -ne $successavstate)

{

#create the Log and save

Start-Sleep -Milliseconds $rdom

$Log = $env:COMPUTERNAME + "; " + $av.displayName + "; " + $tohex + "; " + $CuDate

$Log | Out-File -FilePath $destination -append -Force

}

}

}

Open the ConfigMgr console and navigate to \Software Library\Overview\Scripts

Select Create Script:1_av
Paste the script with your modified UNC-Share Path:

2_av

Save the Script:
3_av

Approve the Script:
4_av
5_av
6_Av

Run the Script against the required device collection:
7_av

Check the result in the log / in my case all clients have a disabled Microsoft Defender and they are up to date. As we are using Sophos Antivirus the result is as expected:
8_av

You can modify the script to check also the state of your 3rd party Antivirus Software. Here you can find the script for Sophos:

#currentdate

$CuDate = Get-Date

$CuDate.ToUniversalTime()

#generate random sleep time between 1-10 milliseconds

$rdom = Get-Random -Maximum 10

#logdestination

$destination = "\\servername\sharename$\AvInfo_Sophos_SCCM.log"

#get Antivirus

$avWMIres = get-wmiobject -namespace root\SecurityCenter2 -computername localhost -Query "Select * from AntiVirusProduct" | where { $_.displayName -eq "Sophos Anti-Virus" }

if ($avWMIres -eq $null)

{

#create the Log and save

Start-Sleep -Milliseconds $rdom

$Log = $env:COMPUTERNAME + "; " + "no Sophos found" + "; " + "0" + "; " + $CuDate

$Log | Out-File -FilePath $aFilePath -append -Force

}

else

{

foreach ($av in $avWMIres)

{

#Sophos enabled and up to date has a hex state of 051000

#Windows Defender

#05 = AV installed

#10 = Active

#00 = u2d

$tohex = [Convert]::ToString($av.productState, 16)

#add zero for hex

$tohex = "0" + $tohex

$successavstate = "051000"

#if not good AV is installed -> add to LOG

If ($tohex -ne $successavstate)

{

#create the Log and save

Start-Sleep -Milliseconds $rdom

$Log = $env:COMPUTERNAME + "; " + $av.displayName + "; " + $tohex + "; " + $CuDate

$Log | Out-File -FilePath $destination -append -Force

}

}

}

The result in the Logs looks like the following. In my case I have a few Clients where Sophos is not up to date and the Antivirus-Team needs to check the clients:
9_av.png

OSD progress hidden behind a “Just a moment” screen Windows 10 1709 -> Fix

OSD progress hidden behind a “Just a moment” screen Windows 10 1709 -> Fix

I noticed an issue when deploying Windows 10 1709 via Task-Sequence-> after the first reboot during the step “Setup Windows and Configuration Manager” the machine came back with “Just a moment” and the progress bar was hidden. My task-sequence had no unattend file applied during the capture. I found the solution by creating an unattend file that hide’s Wifi Setup and disabled user and computer OOBE. The step was added during the step “Apply Operating System”:

The XML-File includes the following:

<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="oobeSystem">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="‪http://schemas.microsoft.com/WMIConfig/2002/State‬" xmlns:xsi="‪http://www.w3.org/2001/XMLSchema-instance‬">
<OOBE>
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
<NetworkLocation>Work</NetworkLocation>
<SkipMachineOOBE>true</SkipMachineOOBE>
<SkipUserOOBE>true</SkipUserOOBE>
</OOBE>
</component>
</settings>
<cpi:offlineImage cpi:source="wim:c:/mount/install.wim#Windows 10 Enterprise" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>

Setup Corporate Identity in Software Center SCCM 1710 and a BUG?

In this post I’ll show you quickly how you can setup your Corporate Identity in SCCM 1710. Make sure you have updated your client also after the upgrade.

-> Create a new custom device setting or edit the default one under \Administration\Overview\Client Settings

-> Activte the new settings with YES

-> Enter a Company Name -> you can also leave it empty

-> Select the color scheme

-> Select your logo -> the size can be 100x400x pixel and 750kb and in the following format png, jpg, bmp

-> Enable or Disable the options in the Software Center

I may noticed a BUG. If you enter a “&” in the company name field the settings are not applied.

clientsettings

With my settings my Softwarecenter looks now like this – I really love it!!

software

Powershell GUI ConfigMgr to create AD Groups and Deployments

Target: Create AD-Groups for Installation / Uninstallation then create Installation/Uninstallation device collection in ConfigMgr and create the deployment for the application

New Version published. Download here
One version which runs with remote PowerShell like the first version.

And one version which runs localy. Prerequisites SCCM-Console installed / and the Windows Remote-Tools / Active Directory

1

The new version includes a few bug fixes and a few new tabs. To deploy multiple applications.

2017-11-17 17_52_48-2.png ‎- Fotos

 

Prerequisites: Permission on Active-Directory and SCCM to create collections -> run the .exe as different user as required, Active-Directory Powershell extension, Modify the xml-file

This is my first Powershell GUI that I’ll share – I’m not a PowerShell Pro so please be fair.

Run the .ps1 file with a user with write-permission in AD and the permission to create device collections and deployments in ConfigMgr.

Enter the Name of the Group to create in AD:

Click on OU: an Active-Directory Popup will appear to select the required OU / you can also create new OU’s:

Same for the Uninstallation Group:

Once finsihed click on Next:

On the next page you need to enter the application you want to deploy / just click in the windows and it’ll query all available Applications from  ConfigMgr:

In the Grid-View you can use Filter/Search:

Select the Deployment Type (Avaialbe, Required) and once the deployment should be go live:

Then you can select Finish and the Progress-Bar will run:

The result in Active Directory and ConfigMgr:

In ConfigMgr:

The AD-Group Query in the created device collection:

The Deployments:

The program already has some error handling / in step1 there is a check if the group name is already in use:

Also it checks if it can connect to the ConfigMgr and if Active-Directory Module is installed:

Modify the XML-File with your data – this will be loaded on .exe startup:

ConfigMgr GUI query device affinity Primary User / Device

Target: Get primary devices from users / get primary users from device or with csv import possibility

Requirements: ConfigMgr Console needs to be installed and the user requires the permission to query primary device / primary user. And device affinity needs to be configured in ConfigMgr

https://technet.microsoft.com/en-us/library/gg699365.aspx

Run the .exe with a user which has permission to query the primary user / primary device information in Configmgr.

Download: click here

You can query a singel user / click on Run and you get the device:

1

You can query a singel computer / click on Run and you get the user:

2

Or you click on “CSV” then you can select a CSV-File to query multiple users or devices. An example .csv file is included in the sources. The result will be shown in an grid view. And the result will be exported in an csv to C:\temp\primary_users_device

3

4

Please modify the MP.xml before you start the .exe file. Enter the name of your ConfigMgr-Server. Your Site-Code and your AD-Domain-Name.

5

The program was created in Sapiens Powershell-Studio 2017. I’ll publish the .exe Version but if want the .psf file – just let me know.

Send Mail if there is an error in Task-Sequence

Target: Send mail / smsts.log if there is an error in a task-sequence to support or helpdesk

In one of my previous post I discripted howto “Copy the smsts.log to a network share during a task-sequence if there is any error in the task-sequence” -> I modified the last step -> to send a mail directly to the helpdesk if there was an error in the task-sequence.

I wrote a small GUI that will be shown if there was an error in a task-sequence. The tool automatically pre-fills the subject with the computername / the mail to from the config file and the mail-body.

This is the view in the task-sequence once an error occurs:

1

2

And the result in the mailbox of the helpdesk / or in the ticket system:

3

Download the tool from the following link: click here

The download includes the .exe file and a config xml file:

4

You need to adapt the config.xml with your configuration details:

5

Enter your smtp server with the port. Enter the mail details from: to:

If you set active to “no” that would mean that your SMTP-Server accepts mails from anonymous. In that case you can skip the username and password in the Config.xml

Enter the logshare name -> the once that is configured in the “Connect to Network Folder” step in the task-sequence.

Afterwards place both files in a package and deploy it to the required distribution-points and add the following step in the task-sequence in the part “Log Capture”:

6

7

There is one prerequisite – you need to active Windows Powershell Support in your boot image configured in the task-sequence.

8

Powershell GUI ConfigMgr to create AD Groups and Deployments

Target: Create AD-Groups for Installation / Uninstallation then create Installation/Uninstallation device collection in ConfigMgr and create the deployment for the application

Prerequisites: Permission on Active-Directory and SCCM to create collections -> run the .exe as different user as required, Active-Directory Powershell extension, Modify the xml-file

This is my first Powershell GUI that I’ll share – I’m not a PowerShell Pro so please be fair.

Run the .ps1 file with a user with write-permission in AD and the permission to create device collections and deployments in ConfigMgr.

Enter the Name of the Group to create in AD:

Click on OU: an Active-Directory Popup will appear to select the required OU / you can also create new OU’s:

Same for the Uninstallation Group:

Once finsihed click on Next:

On the next page you need to enter the application you want to deploy / just click in the windows and it’ll query all available Applications from  ConfigMgr:

In the Grid-View you can use Filter/Search:

Select the Deployment Type (Avaialbe, Required) and once the deployment should be go live:

Then you can select Finish and the Progress-Bar will run:

The result in Active Directory and ConfigMgr:

In ConfigMgr:

The AD-Group Query in the created device collection:

The Deployments:

The program already has some error handling / in step1 there is a check if the group name is already in use:

Also it checks if it can connect to the ConfigMgr and if Active-Directory Module is installed:

Modify the XML-File with your data – this will be loaded on .exe startup:

You can use the source Code. Save the ps1 file and the xml file in the same folder. Run the ps1 File with a user which has access to Active-Dirctory and to ConfigMgr.

For the PS1-File:

<#
    .NOTES
    --------------------------------------------------------------------------------
     Code generated by:  SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.144
     Generated on:       08.10.2017 17:07
     Generated by:       André Vogt @sccmlive
     
    --------------------------------------------------------------------------------
    .DESCRIPTION
        GUI script generated by PowerShell Studio 2017
	Active Directory OU Picker Script can be found on: https://itmicah.wordpress.com/2016/03/29/active-directory-ou-picker-revisited/
#>



#----------------------------------------------
#region Application Functions
#----------------------------------------------

#endregion Application Functions

#----------------------------------------------
# Generated Form Function
#----------------------------------------------
function Show-appdeployapplication_psf {

	#----------------------------------------------
	#region Import the Assemblies
	#----------------------------------------------
	[void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
	[void][reflection.assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
	[void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
	#endregion Import Assemblies

	#----------------------------------------------
	#region Generated Form Objects
	#----------------------------------------------
	[System.Windows.Forms.Application]::EnableVisualStyles()
	$formKURZDeploymentTool = New-Object 'System.Windows.Forms.Form'
	$textboxstat = New-Object 'System.Windows.Forms.TextBox'
	$trackbar1 = New-Object 'System.Windows.Forms.TrackBar'
	$richtextboxStatus = New-Object 'System.Windows.Forms.RichTextBox'
	$buttonCancel = New-Object 'System.Windows.Forms.Button'
	$buttonBack = New-Object 'System.Windows.Forms.Button'
	$buttonFinish = New-Object 'System.Windows.Forms.Button'
	$tabcontrolWizard = New-Object 'System.Windows.Forms.TabControl'
	$tabpageStep1 = New-Object 'System.Windows.Forms.TabPage'
	$labelOU = New-Object 'System.Windows.Forms.Label'
	$textboxInOU = New-Object 'System.Windows.Forms.TextBox'
	$textboxInstallName = New-Object 'System.Windows.Forms.TextBox'
	$labelName = New-Object 'System.Windows.Forms.Label'
	$ADGroup = New-Object 'System.Windows.Forms.GroupBox'
	$groupbox6 = New-Object 'System.Windows.Forms.GroupBox'
	$labelLanguage = New-Object 'System.Windows.Forms.Label'
	$textboxUninstallName = New-Object 'System.Windows.Forms.TextBox'
	$labelAppName = New-Object 'System.Windows.Forms.Label'
	$textboxUnOU = New-Object 'System.Windows.Forms.TextBox'
	$groupbox5 = New-Object 'System.Windows.Forms.GroupBox'
	$tabpageStep2 = New-Object 'System.Windows.Forms.TabPage'
	$progressbar1 = New-Object 'System.Windows.Forms.ProgressBar'
	$labelDeploymentType = New-Object 'System.Windows.Forms.Label'
	$groupbox2 = New-Object 'System.Windows.Forms.GroupBox'
	$datetimestart = New-Object 'System.Windows.Forms.DateTimePicker'
	$labelDeploymentStarttime = New-Object 'System.Windows.Forms.Label'
	$comboboxdeploytype = New-Object 'System.Windows.Forms.ComboBox'
	$labelApplicationName = New-Object 'System.Windows.Forms.Label'
	$textboxAppName = New-Object 'System.Windows.Forms.TextBox'
	$buttonNext = New-Object 'System.Windows.Forms.Button'
	$openfiledialog1 = New-Object 'System.Windows.Forms.OpenFileDialog'
	$colordialog1 = New-Object 'System.Windows.Forms.ColorDialog'
	$errorprovider1 = New-Object 'System.Windows.Forms.ErrorProvider'
	$InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
	#endregion Generated Form Objects

	#----------------------------------------------
	# User Generated Script
	#----------------------------------------------
	
	#-------------------------------------------------------
	# NOTE: When new TabPage added place the validation code
	# 		in the Test-WizardPage function.
	#-------------------------------------------------------
	
	# Check if the ActiveDirectory module is <finstalled
	$textboxstat.Text = $NULL
	if ((Get-Module -ListAvailable | where { $_.Name -eq 'ActiveDirectory' }) -eq $null)
	{
		$textboxstat.Text = "Install AD-Module"
		$log += $textboxstat.Text
		$richtextboxStatus.BackColor = 'Red'
		
	}
	else
	{
		# Check if the ActiveDirectory module is allready Imported
		If ((Get-Module ActiveDirectory) -eq $null)
		{
			Import-Module ActiveDirectory -ErrorAction 'SilentlyContinue'
			$richtextboxStatus.BackColor = 'Green'
			$textboxstat.Text = "`nAD-Module loaded`n"
			$log += $textboxstat.Text
		
			
		}
		else
		{
			$textboxstat.Text = "AD-Module aleady loaded`n"
			$log += $textboxstat.Text
		}
	}
	$xml = [XML] (Get-Content -Path .\MP.xml)
	$sccm = $xml.MP.Name
	$sitecode = $xml.MP.Code
	$module = $xml.MP.module
        $domainn = $xml.MP.domainname
	
	
	$textboxstat.Text = "`nXML-File used`n"
	$log += $textboxstat.Text
	
	Try
	{
		$sess = New-PSSession -ComputerName $sccm -ConfigurationName Microsoft.PowerShell32 -EA Stop
		$textboxstat.Text = "Remote Session connected`n"
		$log += $textboxstat.Text
	}
	catch
	{
	
		$textboxstat.Text = "Remote Session not loaded"
		$richtextboxStatus.BackColor = 'RED'
		$log += $textboxstat.Text
	}
	
	
	Try
	{
		Invoke-Command -Session $sess -ScriptBlock {
			param(
			$sitecode,
			$module)
			
			Import-module $module
			
			cd $sitecode
			
			gci
		} -ArgumentList $sitecode, $module
	}
	catch
	{
		
		$textboxstat.Text = "Remote Session not loaded"
		$richtextboxStatus.BackColor = 'RED'
		$log += $textboxstat.Text
	}
	
	
	
	#$textboxstat.Text = "Remote Session not loaded"
		#$log += $textboxstat.Text
		#$richtextboxStatus.BackColor = 'RED'
	
	Try
	{
		$apps = Invoke-Command -Session $sess -ScriptBlock {
			(Get-CMApplication -fast).LocalizedDisplayName
		}
	}
	
	catch
	{
		
		$textboxstat.Text = "Remote Session not loaded / rerun with Admin User"
		$richtextboxStatus.BackColor = 'RED'
		$log += $textboxstat.Text
		
		
	}
	
	
	function Test-WizardPage
	{
	<#
		Add TabPages and place the validation code in this function
	#>
		[OutputType([boolean])]
		param([System.Windows.Forms.TabPage]$tabPage)
		
		if($tabPage -eq $tabpageStep1)
		{
			#TODO: Enter Validation Code here for Step 1
			if ($textboxInstallName.Text -and
				$textboxInstallName.ForeColor -ne 'Red' -and
				$textboxInOU.Text -and
				$textboxUninstallName.Text -and
				$textboxUninstallName.ForeColor -ne 'Red' -and
				$textboxUnOU.Text
				)
			{
				return $true
			}
			
			return $false
		}
		elseif ($tabPage -eq $tabpageStep2)
		{
			#TODO: Enter Validation Code here for Step 2
			if ($textboxAppName.Text -and
				$comboboxdeploytype.Text
				)
			{
				return $true
			}
			
			return $false
		}
		
		#Add more pages here
		
		return $false
	}
	
	
	
	$buttonFinish_Click={
		#-------------------------------------------------------
		# TODO: Place finalization script here
		#-------------------------------------------------------
		#create ad groups
		$installdes = "For installation of the application: "
		$installdes_fin = $installdes + $textboxAppName.Text
		$uninstalldes = "For uninstallation of the application: "
		$uninstalldes_fin = $uninstalldes + $textboxAppName.Text
		
		New-ADGroup -DisplayName $textboxInstallName.Text -name $textboxInstallName.Text -Path $textboxInOU.Text -GroupCategory Security -GroupScope Global -Description $installdes_fin
		$progressbar1.Value = 10
		New-ADGroup -DisplayName $textboxUninstallName.Text  -name $textboxUninstallName.Text -Path $textboxUnOU.Text -GroupCategory Security -GroupScope Global -Description $uninstalldes_fin
		$progressbar1.Value = 20
		#create collection
		$sess = New-PSSession -ComputerName $sccm -ConfigurationName Microsoft.PowerShell32
		$progressbar1.Value = 50
		Invoke-Command -Session $sess -ScriptBlock {
			param ($sitecode,
			$module)
			
			Import-module $module
			
			cd $sitecode
			
			gci
		} -ArgumentList $sitecode, $module
		$progressbar1.Value = 78
		try
		{
			Invoke-Command -Session $sess -ScriptBlock {
				param ($textboxInstallName,
					$textboxUninstallName,
					$textboxAppName,
					$comboboxdeploytype,
					$datetimestart,
					$datetimeend,
$domainn)
				
				#COLLECTION SCHEDULE DATE#
				$ScheduleDate = "06/10/2017 9:00 PM"
				$ScheduleDay = "Friday"
				$Schedule1 = New-CMSchedule -Start $ScheduleDate -DayOfWeek $ScheduleDay -RecurCount 1
				$LimitingCollection = 'All Systems'
				New-CMDeviceCollection -Name $textboxInstallName.Text -LimitingCollectionName $LimitingCollection -RefreshSchedule $Schedule1 -RefreshType Both
				New-CMDeviceCollection -Name $textboxUninstallName.Text -LimitingCollectionName $LimitingCollection -RefreshSchedule $Schedule1 -RefreshType Both
				
				#query on collection
				$QueryExp = 'select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.SystemGroupName ='
				$DomainName = $domainn
				$INADGrp = "'" + $DomainName + '\\' + $textboxInstallName.Text + "'"
				$UNADGrp = "'" + $DomainName + '\\' + $textboxUninstallName.Text + "'"
				Add-CMUserCollectionQueryMembershipRule -CollectionName $textboxInstallName.Text -QueryExpression $QueryExp$INADGrp -RuleName $textboxInstallName.Text
				Add-CMUserCollectionQueryMembershipRule -CollectionName $textboxUninstallName.Text -QueryExpression $QueryExp$UNADGrp -RuleName $textboxUninstallName.Text
				$progressbar1.Value = 80
				#start deployment
				if ($comboboxdeloytype.text -eq "Required")
				{
					new-CMApplicationDeployment -Name $textboxAppName.Text -CollectionName $textboxInstallName.Text -DeployPurpose $comboboxdeploytype.Text -Verbose -AvailableDateTime $datetimestart.Text -RebootOutsideServiceWindow $False
				}
				else
				{
					new-CMApplicationDeployment -Name $textboxAppName.Text -CollectionName $textboxInstallName.Text -DeployPurpose $comboboxdeploytype.Text -Verbose -AvailableDateTime $datetimestart.Text -RebootOutsideServiceWindow $False
					
					new-CMApplicationDeployment -Name $textboxAppName.Text -CollectionName $textboxUninstallName.Text -DeployAction Uninstall -Verbose -DeployPurpose Required
				}
				
				
				
			} -ArgumentList $textboxInstallName, $textboxUninstallName, $textboxAppName, $comboboxdeploytype, $datetimestart, $datetimeend,$domainn
		}
		catch
		{ $textboxstat.Text = "Remote Session failed to execute Tasks`n" }
		$progressbar1.Value = 100
		Remove-PSSession $sess
		$textboxstat.Text = "Remote Session disconnected`n"
		$log += $textboxstat.Text
		$log += $textboxstat.Text
		
		#$textboxstat.Text = "Remote Session cannot be disconnected`n"
		#$textboxstat.Text = "Check permissions on Remote-Host`n"
		#$log += $textboxstat.Text
		#$log += $textboxstat.Text
		#$richtextboxStatus.BackColor = 'RED'
		#$log >> log.txt
	}
	
	
	
		
	
	
	
	#region Events and Functions
	$formKURZDeploymentTool_Load={
		Update-NavButtons
	}
	
	function Update-NavButtons
	{
		<# 
			.DESCRIPTION
			Validates the current tab and Updates the Next, Prev and Finish buttons.
		#>
		$enabled = Test-WizardPage $tabcontrolWizard.SelectedTab
		$buttonNext.Enabled = $enabled -and ($tabcontrolWizard.SelectedIndex -lt $tabcontrolWizard.TabCount - 1)
		$buttonBack.Enabled = $tabcontrolWizard.SelectedIndex -gt 0
		$buttonFinish.Enabled = $enabled -and ($tabcontrolWizard.SelectedIndex -eq $tabcontrolWizard.TabCount - 1)	
		#Uncomment to Hide Buttons
		#$buttonNext.Visible = ($tabcontrolWizard.SelectedIndex -lt $tabcontrolWizard.TabCount - 1)
		#$buttonFinish.Visible = ($tabcontrolWizard.SelectedIndex -eq $tabcontrolWizard.TabCount - 1)
	}
	
	$script:DeselectedIndex = -1
	$tabcontrolWizard_Deselecting=[System.Windows.Forms.TabControlCancelEventHandler]{
	#Event Argument: $_ = [System.Windows.Forms.TabControlCancelEventArgs]
		# Store the previous tab index
		$script:DeselectedIndex = $_.TabPageIndex
	}
	
	$tabcontrolWizard_Selecting=[System.Windows.Forms.TabControlCancelEventHandler]{
	#Event Argument: $_ = [System.Windows.Forms.TabControlCancelEventArgs]
		# We only validate if we are moving to the Next TabPage. 
		# Users can move back without validating
		if($script:DeselectedIndex -ne -1 -and $script:DeselectedIndex -lt $_.TabPageIndex)
		{
			#Validate each page until we reach the one we want
			for($index = $script:DeselectedIndex; $index -lt $_.TabPageIndex; $index++)
			{
				$_.Cancel = -not (Test-WizardPage $tabcontrolWizard.TabPages[$index])
				
				if($_.Cancel) 
				{
					# Cancel and Return if validation failed.
					return;
				}
			}
		}
		
		Update-NavButtons
	}
	
	$buttonBack_Click={
		#Go to the previous tab page
		if($tabcontrolWizard.SelectedIndex -gt 0)
		{
			$tabcontrolWizard.SelectedIndex--
		}
	}
	
	$buttonNext_Click={	
		#Go to the next tab page
		if($tabcontrolWizard.SelectedIndex -lt $tabcontrolWizard.TabCount - 1)
		{
			$tabcontrolWizard.SelectedIndex++
		}
	}
	
	#endregion
	
	#------------------------------------------------------
	# NOTE: When a Control State changes you should call
	# 		Update-NavButtons to trigger validation
	#------------------------------------------------------
	
	$textboxInstallName_TextChanged = {
		try
		{
			$intest = Get-ADGroup $textboxInstallName.Text
			if ($intest -ne $null)
			{
				$textboxInstallName.Text = "Group-Name already exists"
				$textboxInstallName.ForeColor = "RED"
				$richtextboxStatus.BackColor = 'Red'
				
			}
		}
		catch
		{
			
				Update-NavButtons
				$textboxInstallName.ForeColor = 'Black'
				$richtextboxStatus.BackColor = 'Green'
				
		}
		
		
	}
	
	
	$checkboxCheckToContinue_CheckedChanged={
		Update-NavButtons
	}
	
	$radiobuttonOption_CheckedChanged={
		
		if($this.Checked)
		{
			Update-NavButtons
		}
	}
	
	#region Control Helper Functions
	function Update-DataGridView
	{
		<#
		.SYNOPSIS
			This functions helps you load items into a DataGridView.
	
		.DESCRIPTION
			Use this function to dynamically load items into the DataGridView control.
	
		.PARAMETER  DataGridView
			The DataGridView control you want to add items to.
	
		.PARAMETER  Item
			The object or objects you wish to load into the DataGridView's items collection.
		
		.PARAMETER  DataMember
			Sets the name of the list or table in the data source for which the DataGridView is displaying data.
	
		.PARAMETER AutoSizeColumns
		    Resizes DataGridView control's columns after loading the items.
		#>
		Param (
			[ValidateNotNull()]
			[Parameter(Mandatory=$true)]
			[System.Windows.Forms.DataGridView]$DataGridView,
			[ValidateNotNull()]
			[Parameter(Mandatory=$true)]
			$Item,
		    [Parameter(Mandatory=$false)]
			[string]$DataMember,
			[System.Windows.Forms.DataGridViewAutoSizeColumnMode]$AutoSizeColumns = 'None'
		)
		$DataGridView.SuspendLayout()
		$DataGridView.DataMember = $DataMember
		
		if ($Item -is [System.Data.DataSet] -and $Item.Tables.Count -gt 0)
		{
			$DataGridView.DataSource = $Item.Tables[0]
		}
		elseif ($Item -is [System.ComponentModel.IListSource]`
		-or $Item -is [System.ComponentModel.IBindingList] -or $Item -is [System.ComponentModel.IBindingListView] )
		{
			$DataGridView.DataSource = $Item
		}
		else
		{
			$array = New-Object System.Collections.ArrayList
			
			if ($Item -is [System.Collections.IList])
			{
				$array.AddRange($Item)
			}
			else
			{
				$array.Add($Item)
			}
			$DataGridView.DataSource = $array
		}
		
		if ($AutoSizeColumns -ne 'None')
		{
			$DataGridView.AutoResizeColumns($AutoSizeColumns)
		}
		
		$DataGridView.ResumeLayout()
	}
	
	function ConvertTo-DataTable
	{
		<#
			.SYNOPSIS
				Converts objects into a DataTable.
		
			.DESCRIPTION
				Converts objects into a DataTable, which are used for DataBinding.
		
			.PARAMETER  InputObject
				The input to convert into a DataTable.
		
			.PARAMETER  Table
				The DataTable you wish to load the input into.
		
			.PARAMETER RetainColumns
				This switch tells the function to keep the DataTable's existing columns.
			
			.PARAMETER FilterWMIProperties
				This switch removes WMI properties that start with an underline.
		
			.EXAMPLE
				$DataTable = ConvertTo-DataTable -InputObject (Get-Process)
		#>
		[OutputType([System.Data.DataTable])]
		param(
		[ValidateNotNull()]
		$InputObject, 
		[ValidateNotNull()]
		[System.Data.DataTable]$Table,
		[switch]$RetainColumns,
		[switch]$FilterWMIProperties)
		
		if($null -eq $Table)
		{
			$Table = New-Object System.Data.DataTable
		}
		
		if ($InputObject -is [System.Data.DataTable])
		{
			$Table = $InputObject
		}
		elseif ($InputObject -is [System.Data.DataSet] -and $InputObject.Tables.Count -gt 0)
		{
			$Table = $InputObject.Tables[0]
		}
		else
		{
			if (-not $RetainColumns -or $Table.Columns.Count -eq 0)
			{
				#Clear out the Table Contents
				$Table.Clear()
				
				if ($null -eq $InputObject) { return } #Empty Data
				
				$object = $null
				#find the first non null value
				foreach ($item in $InputObject)
				{
					if ($null -ne $item)
					{
						$object = $item
						break
					}
				}
				
				if ($null -eq $object) { return } #All null then empty
				
				#Get all the properties in order to create the columns
				foreach ($prop in $object.PSObject.Get_Properties())
				{
					if (-not $FilterWMIProperties -or -not $prop.Name.StartsWith('__')) #filter out WMI properties
					{
						#Get the type from the Definition string
						$type = $null
						
						if ($null -ne $prop.Value)
						{
							try { $type = $prop.Value.GetType() }
							catch { Out-Null }
						}
						
						if ($null -ne $type) # -and [System.Type]::GetTypeCode($type) -ne 'Object')
						{
							[void]$table.Columns.Add($prop.Name, $type)
						}
						else #Type info not found
						{
							[void]$table.Columns.Add($prop.Name)
						}
					}
				}
				
				if ($object -is [System.Data.DataRow])
				{
					foreach ($item in $InputObject)
					{
						$Table.Rows.Add($item)
					}
					return @( ,$Table)
				}
			}
			else
			{
				$Table.Rows.Clear()
			}
			
			foreach ($item in $InputObject)
			{
				$row = $table.NewRow()
				
				if ($item)
				{
					foreach ($prop in $item.PSObject.Get_Properties())
					{
						if ($table.Columns.Contains($prop.Name))
						{
							$row.Item($prop.Name) = $prop.Value
						}
					}
				}
				[void]$table.Rows.Add($row)
			}
		}
		
		return @(,$Table)	
	}
	
	function Update-ComboBox
	{
	<#
		.SYNOPSIS
			This functions helps you load items into a ComboBox.
		
		.DESCRIPTION
			Use this function to dynamically load items into the ComboBox control.
		
		.PARAMETER ComboBox
			The ComboBox control you want to add items to.
		
		.PARAMETER Items
			The object or objects you wish to load into the ComboBox's Items collection.
		
		.PARAMETER DisplayMember
			Indicates the property to display for the items in this control.
		
		.PARAMETER Append
			Adds the item(s) to the ComboBox without clearing the Items collection.
		
		.EXAMPLE
			Update-ComboBox $combobox1 "Red", "White", "Blue"
		
		.EXAMPLE
			Update-ComboBox $combobox1 "Red" -Append
			Update-ComboBox $combobox1 "White" -Append
			Update-ComboBox $combobox1 "Blue" -Append
		
		.EXAMPLE
			Update-ComboBox $combobox1 (Get-Process) "ProcessName"
		
		.NOTES
			Additional information about the function.
	#>
		
		param
		(
			[Parameter(Mandatory = $true)]
			[ValidateNotNull()]
			[System.Windows.Forms.ComboBox]
			$ComboBox,
			[Parameter(Mandatory = $true)]
			[ValidateNotNull()]
			$Items,
			[Parameter(Mandatory = $false)]
			[string]
			$DisplayMember,
			[switch]
			$Append
		)
		
		if (-not $Append)
		{
			$ComboBox.Items.Clear()
		}
		
		if ($Items -is [Object[]])
		{
			$ComboBox.Items.AddRange($Items)
		}
		elseif ($Items -is [System.Collections.IEnumerable])
		{
			$ComboBox.BeginUpdate()
			foreach ($obj in $Items)
			{
				$ComboBox.Items.Add($obj)
			}
			$ComboBox.EndUpdate()
		}
		else
		{
			$ComboBox.Items.Add($Items)
		}
		
		$ComboBox.DisplayMember = $DisplayMember
	}
	#endregion
	
	$openfiledialog1_FileOk=[System.ComponentModel.CancelEventHandler]{
	#Event Argument: $_ = [System.ComponentModel.CancelEventArgs]
		#TODO: Place custom script here
		
	}
	
	
	
	$textboxUninstallName_TextChanged={
		#TODO: Place custom script here
		try
		{
			$unintest = Get-ADGroup $textboxUninstallName.Text
			if ($unintest -ne $null)
			{
				$textboxUninstallName.Text = "Group-Name already exists"
				$textboxUninstallName.ForeColor = "RED"
				$richtextboxStatus.BackColor = 'Red'
				
			}
		}
		catch
		{
			
			Update-NavButtons
			$textboxUninstallName.ForeColor = 'Black'
			$richtextboxStatus.BackColor = 'Green'
			
		}
		
		
	}
	
	$textboxUnOU_TextChanged={
		#TODO: Place custom script here
		Update-NavButtons
		
	}
	
	$textboxarchi_TextChanged={
		#TODO: Place custom script here
		Update-NavButtons
	}
	
	$textboxSPath_TextChanged={
		#TODO: Place custom script here
		Update-NavButtons
	}
	
	$textboxDPath_TextChanged={
		#TODO: Place custom script here
		Update-NavButtons
	}
	
	$textboxType_TextChanged={
		#TODO: Place custom script here
		Update-NavButtons
	}
	
	$textboxFile_TextChanged={
		#TODO: Place custom script here
		Update-NavButtons
	}
	
	$textboxParameter_TextChanged={
		#TODO: Place custom script here
		Update-NavButtons
	}
	
	$textboxUntype_TextChanged={
		#TODO: Place custom script here
		Update-NavButtons
	}
	
	$textboxName_Para_TextChanged={
		#TODO: Place custom script here
		Update-NavButtons
	}
	
	$textboxUNamePara_TextChanged={
		#TODO: Place custom script here
		Update-NavButtons
	}
	
	$textboxUType_TextChanged={
		#TODO: Place custom script here
		Update-NavButtons
	}
	
	$textboxSourceOUSCCM_TextChanged={
		#TODO: Place custom script here
		Update-NavButtons
	}
	
	$textboxDestination_DP_TextChanged={
		#TODO: Place custom script here
		Update-NavButtons
	}
	
	$textboxADGROUP_Name_TextChanged={
		#TODO: Place custom script here
		Update-NavButtons
	}
	
	$textboxAD_OU_TextChanged={
		#TODO: Place custom script here
		Update-NavButtons
	}
	
	$textboxinOu_enter = {
		#TODO: Place custom script here
		
		$textboxInOU.Text= (Choose-ADOrganizationalUnit).DistinguishedName
	}
	
	$textboxunOu_enter = {
		#TODO: Place custom script here
		$textboxUnOU.Text = (Choose-ADOrganizationalUnit).DistinguishedName
		
	}
	
	$textboxinOU_TextChanged = {
		#TODO: Place custom script here
		
		Update-NavButtons
		
	}
	
	
	
	
	$textboxappName_TextChanged={
		#TODO: Place custom script here
		Update-NavButtons
	}
	
	$textboxAppName_Enter={
		#TODO: Place custom script here
		
		$app = $apps | Sort-Object | Out-GridView -PassThru -Title 'Select the Application you want to Deploy to the Collection'
		$textboxAppName.Text = $app
		
	}
	
	
	function Choose-ADOrganizationalUnit
	{
		[CmdletBinding()]
		Param
		(
			#FQDN or Distinguished Name of the domain you want to view
			[Parameter(ValueFromPipelineByPropertyName = $true,
					   Position = 0)]
			[Alias("DistinguishedName")]
			[string]$Domain,
			#Credentials for connecting to ActiveDirectory domain
	
			[Parameter(Mandatory = $false,
					   Position = 1)]
			$Credential,
			#Enable Advanced features on startup
	
			[switch]$AdvancedFeatures,
			#Hide the ability to create OU's
	
			[switch]$HideNewOUFeature,
			#Add checkboxes so multiple objects can be selected
	
			[switch]$MultiSelect
		)
		
		
		#region Import the Assemblies
		
		[void][reflection.assembly]::Load("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
		[void][reflection.assembly]::Load("System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
		[void][reflection.assembly]::Load("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
		[void][reflection.assembly]::Load("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
		[void][reflection.assembly]::Load("System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
		[void][reflection.assembly]::Load("System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
		[void][reflection.assembly]::Load("System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
		[void][reflection.assembly]::Load("System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
		[void][reflection.assembly]::Load("System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
		[void][reflection.assembly]::Load("System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
		#endregion Import Assemblies
		
		
		#region Form Objects
		
		[System.Windows.Forms.Application]::EnableVisualStyles()
		$formChooseOU = New-Object 'System.Windows.Forms.Form'
		$cb_AdvancedFeatures = New-Object 'System.Windows.Forms.CheckBox'
		$Treeview = New-Object 'System.Windows.Forms.TreeView'
		$buttonOK = New-Object 'System.Windows.Forms.Button'
		$imagelist = New-Object 'System.Windows.Forms.ImageList'
		$ContextMenu = New-Object 'System.Windows.Forms.ContextMenuStrip'
		$changeDomainToolStripMenuItem = New-Object 'System.Windows.Forms.ToolStripMenuItem'
		$newOUToolStripMenuItem = New-Object 'System.Windows.Forms.ToolStripMenuItem'
		$InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
		#endregion Form Objects
		
		#region Functions
		
		function Show-Error
		{
			Param ([string]$Message)
			
			$msgbox = [System.Windows.Forms.MessageBox]::Show($Message, "Exception Report", 0, 16)
		}
		
		function Test-LDAPConnection
		{
			Param (
				$ComputerName
			)
			$TCPClient = New-Object Net.Sockets.TcpClient
			$TCPClient.Connect($ComputerName, 389)
			$TestOutput = [pscustomobject]@{
				ComputerName   = $ComputerName
				Connected	   = $TCPClient.Connected
				IPAddress	   = ''
			}
			If ($TCPClient.Connected)
			{
				$TestOutput.IPAddress = $TCPClient.Client.RemoteEndPoint.Address.IPAddressToString
			}
			$TCPClient.Close()
			$TestOutput
		}
		
		function Add-Node
		{
			param (
				$RootNode,
				$dname,
				$name,
				$Type,
				$HasChildren = $true
			)
			
			$newNode = new-object System.Windows.Forms.TreeNode
			$newNode.Name = $dname
			$newNode.Text = $name
			If ($HasChildren)
			{
				$newNode.Nodes.Add('') | Out-Null
			}
			switch ($Type)
			{
				organizationalunit	{
					$newnode.ImageIndex = 3
					$newNode.SelectedImageIndex = 3
				}
				Domain 				{
					$newNode.ImageIndex = 2
					$newNode.SelectedImageIndex = 2
				}
				Default
				{
					$newnode.ImageIndex = 0
					$newNode.SelectedImageIndex = 0
				}
			}
			$RootNode.Nodes.Add($newNode) | Out-Null
			$newNode
		}
		
		function Get-NextLevel
		{
			param (
				$RootNode,
				$Type
			)
			
			If ($Type -eq 'Domain')
			{
				$ADObjects = $forest.domains | ?{ $_.Name -eq $RootNode.Text } |
				select -ExpandProperty Children
				$RootNode.Nodes.Clear()
				$ADObjects | % {
					$node = Add-Node -RootNode $RootNode -dname $_.GetDirectoryEntry().distinguishedName -name $_.name -Type $Type
					Get-NextLevel -RootNode $node -Type $Type
				}
			}
			else
			{
				If ($DomainIP)
				{
					If ($Credential)
					{
						$ADsearcher.SearchRoot = New-Object System.DirectoryServices.DirectoryEntry("LDAP://$DomainIP/$($RootNode.Name)", $Credential.UserName, $Credential.GetNetworkCredential().password)
					}
					else
					{
						$ADsearcher.SearchRoot = New-Object System.DirectoryServices.DirectoryEntry("LDAP://$DomainIP/$($RootNode.Name)")
					}
				}
				elseif ($Credential)
				{
					$ADsearcher.SearchRoot = New-Object System.DirectoryServices.DirectoryEntry("LDAP://$($RootNode.Name)", $Credential.UserName, $Credential.GetNetworkCredential().password)
				}
				else
				{
					$ADsearcher.SearchRoot = "LDAP://$($RootNode.Name)"
				}
				$ADsearcher.filter = "(|(objectClass=organizationalUnit)(ObjectClass=container)(ObjectClass=builtinDomain))"
				$ADsearcher.SearchScope = 'OneLevel'
				
				IF ($cb_AdvancedFeatures.Checked)
				{
					$ADObjects = $ADsearcher.FindAll()
				}
				else
				{
					$ADObjects = $ADsearcher.FindAll() | ?{
						$_.Properties['showinadvancedviewonly'][0] -eq $false -or
						$_.Properties['showinadvancedviewonly'][0] -eq $null
					}
				}
				
				If ($ADObjects)
				{
					$RootNode.Nodes.Clear()
					$ADObjects | % {
						$Type = $_.properties.objectclass | ?{ $_ -ne 'top' }
						If ($Credential)
						{
							$ADsearcher.SearchRoot = New-Object System.DirectoryServices.DirectoryEntry($_.Path, $Credential.UserName, $Credential.GetNetworkCredential().password)
						}
						else
						{
							$ADsearcher.SearchRoot = $_.Path
						}
						If ($ADsearcher.FindOne())
						{
							Add-Node $RootNode $_.properties.distinguishedname[0] $_.properties.name[0] -Type $Type -HasChildren $true
						}
						else
						{
							Add-Node $RootNode $_.properties.distinguishedname[0] $_.properties.name[0] -Type $Type -HasChildren $false
						}
					}
				}
			}
		}
		
		function Build-TreeView
		{
			$treeNodes = $Treeview.Nodes[0]
			
			#Generate rootdomain node and add subdomain nodes
			If ($DomainDN)
			{
				$DomainName = $DomainDN.Replace(',DC=', '.').Substring(3)
				$RootDomainNode = Add-Node -dname $DomainDN `
										   -name $DomainName -RootNode $treeNodes -Type Domain
			}
			else
			{
				$CurrentDomain = $Forest.Domains | ?{ $_.Name -eq $env:USERDNSDOMAIN }
				$Domain = $CurrentDomain.GetDirectoryEntry()
				$RootDomainNode = Add-Node -dname $Domain.distinguishedName `
										   -name $CurrentDomain.Name -RootNode $treeNodes -Type Domain
			}
			#Copy the RootDomainNode to parent scope
			New-Variable -Name RootDomainNode -Value $RootDomainNode -Scope 1
			
			$treeNodes.Expand()
			$RootDomainNode.Expand()
		}
		
		function Change-Domain
		{
			#region Form Objects
			
			$formBrowseForDomain = New-Object 'System.Windows.Forms.Form'
			$labelDomains = New-Object 'System.Windows.Forms.Label'
			$TreeviewForest = New-Object 'System.Windows.Forms.TreeView'
			$buttonCancelDomain = New-Object 'System.Windows.Forms.Button'
			$buttonOKDomain = New-Object 'System.Windows.Forms.Button'
			$buttonChangeForest = New-Object 'System.Windows.Forms.Button'
			$InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
			
			#endregion Form Objects
			
			#region Events
			
			$FormEvent_Shown = {
				#Create domains treeview
				$DName = $forest.RootDomain.GetDirectoryEntry().distinguishedName
				$NodeProps = @{
					dname   = $Dname
					name    = $forest.RootDomain.Name
					RootNode = $TreeviewForest
					Type    = 'Domain'
				}
				$RootDomainNode = Add-Node @NodeProps
				Get-NextLevel -RootNode $RootDomainNode -Type Domain
				$TreeviewForest.ExpandAll()
			}
			
			$Form_StateCorrection_Load =
			{
				#Correct the initial state of the form to prevent the .Net maximized form issue
				$formBrowseForDomain.WindowState = $InitialFormWindowState
			}
			
			$Form_Cleanup_FormClosed =
			{
				#Remove all event handlers from the controls
				try
				{
					$formBrowseForDomain.remove_Load($FormEvent_Load)
					$formBrowseForDomain.remove_Load($Form_StateCorrection_Load)
					$formBrowseForDomain.remove_FormClosed($Form_Cleanup_FormClosed)
					$TreeviewForest.remove_DoubleClick($TreeviewForest_DoubleClick)
				}
				catch [Exception]
				{ }
			}
			
			$TreeviewForest_DoubleClick = {
				#Click OK Button
				If ($TreeviewForest.SelectedNode.Nodes.Count -eq 0)
				{
					$buttonOKDomain.PerformClick()
				}
			}
			
			$buttonChangeForest_Click = {
				$Refresh = $false
				New-Variable -Name ChangeForest -Value (Change-Forest) -Scope 1 -Force
				If ($ChangeForest.Forest)
				{
					$forest = $ChangeForest.Forest
					$Refresh = $true
				}
				If ($ChangeForest.Credential)
				{
					$Credential = $ChangeForest.Credential
					$Refresh = $true
				}
				If ($Refresh)
				{
					$TreeviewForest.Nodes.Clear()
					$TreeviewForest.Refresh()
					& $FormEvent_Shown
				}
			}
			
			#endregion Events
			
			#region Form Code
			
			#
			# formBrowseForDomain
			#
			$formBrowseForDomain.Controls.Add($labelDomains)
			$formBrowseForDomain.Controls.Add($TreeviewForest)
			$formBrowseForDomain.Controls.Add($buttonCancelDomain)
			$formBrowseForDomain.Controls.Add($buttonOKDomain)
			$formBrowseForDomain.Controls.Add($buttonChangeForest)
			$formBrowseForDomain.AcceptButton = $buttonOKDomain
			$formBrowseForDomain.CancelButton = $buttonCancelDomain
			$formBrowseForDomain.ClientSize = '284, 279'
			$formBrowseForDomain.FormBorderStyle = 'FixedDialog'
			$formBrowseForDomain.MaximizeBox = $False
			$formBrowseForDomain.MinimizeBox = $False
			$formBrowseForDomain.Name = "formBrowseForDomain"
			$formBrowseForDomain.StartPosition = 'CenterScreen'
			$formBrowseForDomain.Text = "Browse for Domain"
			$formBrowseForDomain.add_Shown($FormEvent_Shown)
			#
			# labelDomains
			#
			$labelDomains.Location = '12, 9'
			$labelDomains.Name = "labelDomains"
			$labelDomains.Size = '99, 16'
			$labelDomains.TabIndex = 2
			$labelDomains.Text = "Domains:"
			#
			# TreeviewForest
			#
			$TreeviewForest.Location = '12, 28'
			$TreeviewForest.ImageList = $imagelist
			$TreeviewForest.ImageIndex = 2
			$TreeviewForest.Name = "TreeviewForest"
			$TreeviewForest.Size = '260, 193'
			$TreeviewForest.TabIndex = 1
			$TreeviewForest.add_DoubleClick($TreeviewForest_DoubleClick)
			#
			# buttonCancelDomain
			#
			$buttonCancelDomain.Anchor = 'Bottom, Right'
			$buttonCancelDomain.DialogResult = 'Cancel'
			$buttonCancelDomain.Location = '197, 244'
			$buttonCancelDomain.Name = "buttonCancelDomain"
			$buttonCancelDomain.Size = '75, 23'
			$buttonCancelDomain.TabIndex = 0
			$buttonCancelDomain.Text = "Can&cel"
			$buttonCancelDomain.UseVisualStyleBackColor = $True
			#
			# buttonOKDomain
			#
			$buttonOKDomain.Anchor = 'Bottom, Right'
			$buttonOKDomain.DialogResult = 'OK'
			$buttonOKDomain.Location = '116, 244'
			$buttonOKDomain.Name = "buttonOKDomain"
			$buttonOKDomain.Size = '75, 23'
			$buttonOKDomain.TabIndex = 0
			$buttonOKDomain.Text = "&OK"
			$buttonOKDomain.UseVisualStyleBackColor = $True
			#
			# buttonChangeForest
			#
			$buttonChangeForest.Anchor = 'Bottom, Left'
			#$buttonChangeForest.DialogResult = 'OK'
			$buttonChangeForest.Location = '13, 244'
			$buttonChangeForest.Name = "buttonChangeForest"
			$buttonChangeForest.Size = '91, 23'
			$buttonChangeForest.TabIndex = 0
			$buttonChangeForest.Text = "Change &Forest"
			$buttonChangeForest.UseVisualStyleBackColor = $True
			$buttonChangeForest.add_Click($buttonChangeForest_Click)
			#endregion Form Code
			
			#Save the initial state of the form
			$InitialFormWindowState = $formBrowseForDomain.WindowState
			#Init the OnLoad event to correct the initial state of the form
			$formBrowseForDomain.add_Load($Form_StateCorrection_Load)
			#Clean up the control events
			$formBrowseForDomain.add_FormClosed($Form_Cleanup_FormClosed)
			#Show the Form
			IF ($formBrowseForDomain.ShowDialog() -eq 'OK')
			{
				If ($ChangeForest)
				{
					$Props = @{
						MemberType   = 'NoteProperty'
						Name		 = 'NewDomainDN'
						Value	     = $TreeviewForest.SelectedNode.Name
					}
					$ChangeForest | Add-Member @Props -PassThru
				}
				else
				{
					[pscustomobject]@{
						NewDomainDN   = $TreeviewForest.SelectedNode.Name
					}
				}
			}
		}
		
		function Change-Forest
		{
			[System.Windows.Forms.Application]::EnableVisualStyles()
			$formChangeForest = New-Object 'System.Windows.Forms.Form'
			$CB_UseCred = New-Object 'System.Windows.Forms.CheckBox'
			$GB_Creds = New-Object 'System.Windows.Forms.GroupBox'
			$MTB_Password = New-Object 'System.Windows.Forms.MaskedTextBox'
			$TB_UserName = New-Object 'System.Windows.Forms.TextBox'
			$labelUsernamePassword = New-Object 'System.Windows.Forms.Label'
			$tb_DCName = New-Object 'System.Windows.Forms.TextBox'
			$labelDomainControllerFQDN = New-Object 'System.Windows.Forms.Label'
			$buttonOK = New-Object 'System.Windows.Forms.Button'
			$InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
			
			$CB_UseCred_CheckedChanged = {
				$GB_Creds.Enabled = $CB_UseCred.Checked
			}
			
			$buttonOK_Click = {
				$formChangeForest.Cursor = 'WaitCursor'
				$ServerName = $tb_DCName.Text
				$UserName = $TB_UserName.Text
				$Password = $MTB_Password.Text
				try
				{
					$LDAPTest = Test-LDAPConnection -ComputerName $ServerName
					If ($LDAPTest.Connected)
					{
						Write-Verbose "Connection successful."
					}
					else
					{
						throw "Unable to connect to server '$ServerName' on LDAP port 389."
					}
					If ($CB_UseCred.Checked)
					{
						$DomainEntry = New-Object System.DirectoryServices.DirectoryEntry("LDAP://$ServerName", $UserName, $Password)
						$SecPwd = $Password | ConvertTo-SecureString -AsPlainText -Force
						$ForestCred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $SecPwd
					}
					else
					{
						$DomainEntry = New-Object System.DirectoryServices.DirectoryEntry("LDAP://$ServerName")
					}
					If ($DomainEntry.Name -eq $null)
					{
						throw "Unable to connect to server '$ServerName'"
					}
					$DomainContext = New-Object System.DirectoryServices.ActiveDirectory.DirectoryContext("Domain", $DomainEntry.name)
					$Domain = [System.DirectoryServices.ActiveDirectory.Domain]::GetDomain($DomainContext)
					$ForestContext = New-Object System.DirectoryServices.ActiveDirectory.DirectoryContext("Forest", $domain.forest)
					$RemoteForest = [System.DirectoryServices.ActiveDirectory.Forest]::GetForest($ForestContext)
					$Props = @{
						Server   = $LDAPTest.IPAddress
					}
					If ($RemoteForest)
					{
						$Props.Add('Forest', $RemoteForest)
					}
					If ($ForestCred)
					{
						$Props.Add('Credential', $ForestCred)
					}
					New-Variable -Name ForestOutput -Scope 1 -Value ([pscustomobject]$Props)
				}
				catch
				{
					$Message = 'Connection failed! ' + $_.exception.message
					$ErrorMsg = [System.Windows.Forms.MessageBox]::Show($Message, "Connection failure", 0, 16)
				}
				$formChangeForest.Cursor = 'Default'
			}
			
			$Form_StateCorrection_Load = {
				#Correct the initial state of the form to prevent the .Net maximized form issue
				$formChangeForest.WindowState = $InitialFormWindowState
			}
			
			$Form_Cleanup_FormClosed = {
				#Remove all event handlers from the controls
				try
				{
					$CB_UseCred.remove_CheckedChanged($CB_UseCred_CheckedChanged)
					$buttonOK.remove_Click($buttonOK_Click)
					$formChangeForest.remove_Load($Form_StateCorrection_Load)
					$formChangeForest.remove_FormClosed($Form_Cleanup_FormClosed)
				}
				catch [Exception]
				{ }
			}
			
			# formChangeForest
			#
			$formChangeForest.Controls.Add($CB_UseCred)
			$formChangeForest.Controls.Add($GB_Creds)
			$formChangeForest.Controls.Add($tb_DCName)
			$formChangeForest.Controls.Add($labelDomainControllerFQDN)
			$formChangeForest.Controls.Add($buttonOK)
			$formChangeForest.AcceptButton = $buttonOK
			$formChangeForest.ClientSize = '253, 222'
			$formChangeForest.FormBorderStyle = 'FixedDialog'
			$formChangeForest.MaximizeBox = $False
			$formChangeForest.MinimizeBox = $False
			$formChangeForest.Name = "formChangeForest"
			$formChangeForest.StartPosition = 'CenterScreen'
			$formChangeForest.Text = "Change Forest"
			#
			# CB_UseCred
			#
			$CB_UseCred.Anchor = 'Bottom, Left'
			$CB_UseCred.Location = '13, 68'
			$CB_UseCred.Name = "CB_UseCred"
			$CB_UseCred.Size = '172, 24'
			$CB_UseCred.TabIndex = 3
			$CB_UseCred.Text = "Use alternate credentials"
			$CB_UseCred.UseVisualStyleBackColor = $True
			$CB_UseCred.add_CheckedChanged($CB_UseCred_CheckedChanged)
			#
			# GB_Creds
			#
			$GB_Creds.Controls.Add($MTB_Password)
			$GB_Creds.Controls.Add($TB_UserName)
			$GB_Creds.Controls.Add($labelUsernamePassword)
			$GB_Creds.Anchor = 'Left, Right'
			$GB_Creds.Enabled = $False
			$GB_Creds.Location = '13, 98'
			$GB_Creds.Name = "GB_Creds"
			$GB_Creds.Size = '227, 83'
			$GB_Creds.TabIndex = 4
			$GB_Creds.TabStop = $False
			$GB_Creds.Text = "Alternate credentials"
			#
			# MTB_Password
			#
			$MTB_Password.Location = '85, 47'
			$MTB_Password.Name = "MTB_Password"
			$MTB_Password.PasswordChar = '*'
			$MTB_Password.Size = '127, 20'
			$MTB_Password.TabIndex = 5
			#
			# TB_UserName
			#
			$TB_UserName.Location = '85, 20'
			$TB_UserName.Name = "TB_UserName"
			$TB_UserName.Size = '127, 20'
			$TB_UserName.TabIndex = 4
			#
			# labelUsernamePassword
			#
			$labelUsernamePassword.Location = '7, 20'
			$labelUsernamePassword.Name = "labelUsernamePassword"
			$labelUsernamePassword.Size = '71, 52'
			$labelUsernamePassword.TabIndex = 0
			$labelUsernamePassword.Text = "Username

Password"
			#
			# tb_DCName
			#
			$tb_DCName.Location = '13, 37'
			$tb_DCName.Name = "tb_DCName"
			$tb_DCName.Size = '227, 20'
			$tb_DCName.TabIndex = 2
			#
			# labelDomainControllerFQDN
			#
			$labelDomainControllerFQDN.Location = '13, 13'
			$labelDomainControllerFQDN.Name = "labelDomainControllerFQDN"
			$labelDomainControllerFQDN.Size = '227, 16'
			$labelDomainControllerFQDN.TabIndex = 1
			$labelDomainControllerFQDN.Text = "Domain Controller (FQDN or IP address):"
			#
			# buttonOK
			#
			$buttonOK.Anchor = 'Bottom, Right'
			$buttonOK.DialogResult = 'OK'
			$buttonOK.Location = '166, 187'
			$buttonOK.Name = "buttonOK"
			$buttonOK.Size = '75, 23'
			$buttonOK.TabIndex = 6
			$buttonOK.Text = "&OK"
			$buttonOK.UseVisualStyleBackColor = $True
			$buttonOK.add_Click($buttonOK_Click)
			
			#Save the initial state of the form
			$InitialFormWindowState = $formChangeForest.WindowState
			#Init the OnLoad event to correct the initial state of the form
			$formChangeForest.add_Load($Form_StateCorrection_Load)
			#Clean up the control events
			$formChangeForest.add_FormClosed($Form_Cleanup_FormClosed)
			#Show the Form
			If ($formChangeForest.ShowDialog() -eq 'OK')
			{
				$ForestOutput
			}
		}
		
		#endregion Functions
		
		#region Script
		
		$FormEvent_Load = {
			
			If ((gwmi win32_computersystem).partofdomain)
			{
				$forest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()
				#Validate Domain variable if present
				If ($Domain)
				{
					If ($Domain -match 'CN=|OU=')
					{
						throw "'$Domain' is not a domain distinguished name."
						$formChooseOU.Close()
					}
					ElseIf ($Domain -match '\w+\.\w+')
					{
						If ($forest.Domains.Name -contains $Domain)
						{
							$DomainDN = "DC=$($Domain.ToUpper())" -replace '\.', ',DC='
						}
						else
						{
							throw "No domain found with FQDN '$Domain'."
							$formChooseOU.Close()
						}
					}
					ElseIf ($Domain -match 'DC=\w+,DC+')
					{
						If ([adsi]::exists("LDAP://$Domain"))
						{
							$DomainDN = $Domain
						}
						else
						{
							throw "'$Domain' does not exist in Active Directory."
							$formChooseOU.Close()
						}
					}
					New-Variable -Name DomainDN -Value $DomainDN -Scope 1
				}
				If ($Credential)
				{
					$Credential = Get-Credential $Credential -Message "Please enter credentials to connect to domain '$Domain'"
					try
					{
						$root = New-Object -TypeName System.DirectoryServices.DirectoryEntry("LDAP://$DomainDN", $Credential.UserName, $Credential.GetNetworkCredential().password)
					}
					catch
					{
						Show-Error "Unable to connect to domain '$Domain'."
						$host.SetShouldExit(1)
						return
					}
				}
				else
				{
					$root = [ADSI]''
				}
				$ADSearcher = New-Object System.DirectoryServices.DirectorySearcher($root)
				New-Variable -Name ADSearcher -Value $ADSearcher -Scope 1
				New-Variable -Name Forest -Value $forest -Scope 1
			}
			elseif ($Domain)
			{
				If ($Domain -match 'CN=|OU=')
				{
					throw "'$Domain' is not a domain distinguished name."
					$formChooseOU.Close()
				}
				If ($Domain -match '\w+\.\w+')
				{
					$DomainDN = "DC=$($Domain.ToUpper())" -replace '\.', ',DC='
				}
				ElseIf ($Domain -match 'DC=\w+,DC+')
				{
					$DomainDN = $Domain
					$Domain = $Domain.Replace('DC=', '.').TrimStart('DC=')
				}
				New-Variable -Name DomainDN -Value $DomainDN -Scope 1
				$Credential = Get-Credential $Credential -Message "Please enter credentials to connect to domain '$Domain'"
				try
				{
					$LDAPTest = Test-LDAPConnection -ComputerName $Domain
					If ($LDAPTest.Connected)
					{
						Write-Verbose "Connection successful."
					}
					else
					{
						throw "Unable to connect to '$Domain' on LDAP port 389."
					}
					$DomainIP = $LDAPTest.IPAddress
					$root = New-Object -TypeName System.DirectoryServices.DirectoryEntry("LDAP://$DomainIP", $Credential.UserName, $Credential.GetNetworkCredential().password)
					New-Variable -Name DomainIP -Value $DomainIP -Scope 1
				}
				catch
				{
					Show-Error "Unable to connect to domain '$Domain'."
					$host.SetShouldExit(1)
					return
				}
				$ADSearcher = new-object System.DirectoryServices.DirectorySearcher($root)
				New-Variable -Name ADSearcher -Value $ADSearcher -Scope 1
			}
			else
			{
				$Domain = Read-Host 'Please enter a domain to connect to'
				If ($Domain)
				{
					& $FormEvent_Load
				}
				else
				{
					return
				}
			}
			If ($Credential)
			{
				Set-Variable -Name Credential -Value $Credential -Scope 1 -Force
			}
			If ($MultiSelect)
			{
				$Treeview.CheckBoxes = $true
			}
			$cb_AdvancedFeatures.Checked = $AdvancedFeatures
			$ADSearcher.PropertiesToLoad.AddRange(@('name', 'distinguishedname'))
		}
		
		$CreateOU = [System.Windows.Forms.NodeLabelEditEventHandler]{
			#Event Argument: $_ = [System.Windows.Forms.NodeLabelEditEventArgs]
			$NewNode = $_.Node
			$Label = $_.Label
			$NewNode.Name = "OU=$Label,$($NewNode.Parent.Name)"
			$objParent = [ADSI]"LDAP://$($NewNode.Parent.Name)"
			$objOU = $objParent.Create("organizationalUnit", "ou=$Label")
			try
			{
				Write-Verbose "Creating OU '$($_.Label)'."
				$objOU.SetInfo()
				
				Write-Verbose "Setting 'protect from accidental deletion'."
				$ObjectSecurity = $objOU.psbase.ObjectSecurity
				$EveryOne = New-Object -TypeName System.Security.Principal.NTAccount -ArgumentList '', 'Everyone'
				$Act = [System.Security.AccessControl.AccessControlType]::Deny
				$ADRights = [System.DirectoryServices.ActiveDirectoryRights]::Delete
				$NewRule = New-Object -TypeName System.DirectoryServices.ActiveDirectoryAccessRule -ArgumentList $EveryOne, $ADRights, $Act
				$ObjectSecurity.AddAccessRule($NewRule)
				$ADRights = [System.DirectoryServices.ActiveDirectoryRights]::DeleteTree
				$NewRule = New-Object -TypeName System.DirectoryServices.ActiveDirectoryAccessRule -ArgumentList $EveryOne, $ADRights, $Act
				$ObjectSecurity.AddAccessRule($NewRule)
				$objOU.psbase.CommitChanges()
			}
			catch [System.UnauthorizedAccessException]
			{
				$TryWithCred = $true
			}
			catch
			{
				$Treeview.SelectedNode = $NewNode.Parent
				$Treeview.Nodes.Remove($NewNode)
				Show-Error -Message $_.Exception.GetBaseException().Message
			}
			If ($TryWithCred)
			{
				try
				{
					If (!$ADWriteCred)
					{
						$Cred = $host.ui.PromptForCredential("Insufficient rights in AD detected", "Please enter credentials with sufficient rights in Active Directory.", "", "NetBiosUserName")
						
						If ($Cred)
						{
							#Create variable in parent scope
							New-Variable -Name ADWriteCred -Value $Cred -Scope 1
						}
						else
						{
							$Treeview.SelectedNode = $NewNode.Parent
							$Treeview.Nodes.Remove($NewNode)
							return
						}
					}
					$DomainDN = ($NewNode.Name.Split(',') | ?{ $_ -like 'DC=*' }) -Join ','
					$objParent = New-Object System.DirectoryServices.DirectoryEntry "LDAP://$($NewNode.Parent.Name)", $($ADWriteCred.UserName), $($ADWriteCred.GetNetworkCredential().password)
					$objOU = $objParent.Create("organizationalUnit", "ou=$Label")
					
					Write-Verbose "Creating OU '$Label'."
					$objOU.SetInfo()
					Write-Verbose "Setting 'protect from accidental deletion'."
					$ObjectSecurity = $objOU.psbase.ObjectSecurity
					$EveryOne = New-Object -TypeName System.Security.Principal.NTAccount -ArgumentList '', 'Everyone'
					$Act = [System.Security.AccessControl.AccessControlType]::Deny
					$ADRights = [System.DirectoryServices.ActiveDirectoryRights]::Delete
					$NewRule = New-Object -TypeName System.DirectoryServices.ActiveDirectoryAccessRule -ArgumentList $EveryOne, $ADRights, $Act
					$ObjectSecurity.AddAccessRule($NewRule)
					$ADRights = [System.DirectoryServices.ActiveDirectoryRights]::DeleteTree
					$NewRule = New-Object -TypeName System.DirectoryServices.ActiveDirectoryAccessRule -ArgumentList $EveryOne, $ADRights, $Act
					$ObjectSecurity.AddAccessRule($NewRule)
					$ADRights = [System.DirectoryServices.ActiveDirectoryRights]::DeleteChild
					$NewRule = New-Object -TypeName System.DirectoryServices.ActiveDirectoryAccessRule -ArgumentList $EveryOne, $ADRights, $Act
					$ObjectSecurity.AddAccessRule($NewRule)
					$objOU.psbase.CommitChanges()
				}
				catch
				{
					$Treeview.SelectedNode = $NewNode.Parent
					$Treeview.Nodes.Remove($NewNode)
					$Text = $_.Exception.Message
					Show-Error -Message $_.Exception.GetBaseException().Message
				}
			}
			$Treeview.LabelEdit = $false
		}
		
		$buttonOK_Click = {
			If ($Treeview.SelectedNode -and !$MultiSelect)
			{
				New-Variable -Scope 1 -Name SelectedObject -Value ([pscustomobject]@{
						Name   = $Treeview.SelectedNode.Text
						DistinguishedName = $Treeview.SelectedNode.Name
					})
			}
		}
		
		$formChooseOU_Shown = {
			#Build treeview when form is shown
			$formChooseOU.Cursor = 'WaitCursor'
			try
			{
				Build-TreeView
			}
			catch
			{
				Show-Error ($_ | Out-String)
			}
			finally
			{
				$formChooseOU.Cursor = 'Default'
			}
		}
		
		$Treeview_BeforeExpand = [System.Windows.Forms.TreeViewCancelEventHandler]{
			#Get next level for current node
			If ($_.Node.Level -ne 0)
			{
				Get-NextLevel -RootNode $_.Node
			}
		}
		
		$cb_AdvancedFeatures_CheckedChanged = {
			#Refresh the treeview
			If ($Treeview.Nodes[0].Nodes)
			{
				$Treeview.Nodes[0].Nodes.Clear()
				& $formChooseOU_Shown
			}
		}
		
		$Treeview_DoubleClick = {
			#Click OK Button
			If ($Treeview.SelectedNode.Nodes.Count -eq 0)
			{
				$buttonOK.PerformClick()
				New-Variable -Scope 1 -Name SelectedObject -Value $SelectedObject
			}
		}
		
		$changeDomainToolStripMenuItem_Click = {
			#call Change Domain form
			$Refresh = $false
			$ChangeDomain = Change-Domain
			If ($ChangeDomain.NewDomainDN)
			{
				New-Variable -Name DomainDN -Value $ChangeDomain.NewDomainDN -Scope 1 -Force
				$Refresh = $true
			}
			else
			{
				return
			}
			If ($ChangeDomain.Forest)
			{
				Set-Variable -Name Forest -Value $ChangeDomain.forest -Scope 1 -Force
				New-Variable -Name DomainIP -Value $ChangeDomain.server -Scope 1 -Force
				$Refresh = $true
			}
			If ($ChangeDomain.Credential)
			{
				Set-Variable -Name Credential -Value $ChangeDomain.Credential -Scope 1 -Force
				$Refresh = $true
			}
			If ($Refresh)
			{
				$Treeview.Nodes[0].Nodes.Clear()
				$Treeview.Refresh()
				Build-TreeView
			}
		}
		
		$newOUToolStripMenuItem_Click = {
			#Create new node and edit the label
			$SelectedObject = $Treeview.SelectedNode
			If (!$SelectedObject.IsExpanded)
			{
				$SelectedObject.Expand()
			}
			$newOuNode = new-object System.Windows.Forms.TreeNode
			$newOuNode.text = "New OU"
			$newOuNode.Name = "New OU Name"
			$newOuNode.ImageIndex = 3
			$newOuNode.SelectedImageIndex = 3
			$SelectedObject.Nodes.Add($newOuNode) | Out-Null
			$Treeview.SelectedNode = $NewOUNode
			$Treeview.LabelEdit = $true
			$newOuNode.BeginEdit()
		}
		
		$Treeview_NodeMouseClick = [System.Windows.Forms.TreeNodeMouseClickEventHandler]{
			#Event Argument: $_ = [System.Windows.Forms.TreeNodeMouseClickEventArgs]
			if ($_.Button -eq 'Right')
			{
				$Treeview.SelectedNode = $_.Node
				if ($_.Node.ImageIndex -eq 0)
				{
					return
				}
				$ContextMenu.Items.Clear()
				if ($_.Node.ImageIndex -lt 3 -and (gwmi win32_computersystem).partofdomain)
				{
					$ContextMenu.Items.Add($changeDomainToolStripMenuItem)
				}
				if ($_.Node.ImageIndex -gt 1 -and !$HideNewOUFeature)
				{
					$ContextMenu.Items.Add($newOUToolStripMenuItem)
				}
				If ($ContextMenu.Items.Count -gt 0)
				{
					$ContextMenu.Show($Treeview, $_.Location)
				}
			}
		}
		
		$Treeview_BeforeCheck = [System.Windows.Forms.TreeViewCancelEventHandler]{
			#Event Argument: $_ = [System.Windows.Forms.TreeViewCancelEventArgs]
			#Prevent checking root node
			if ($_.Node.ImageIndex -eq 1)
			{
				$_.Cancel = $true
			}
		}
		
		$Treeview_AfterCheck = [System.Windows.Forms.TreeViewEventHandler]{
			#Event Argument: $_ = [System.Windows.Forms.TreeViewEventArgs]
			If (!$SelectedObject)
			{
				New-Variable -Name SelectedObject -Scope 1 -Value (New-Object collections.arraylist)
			}
			If ($_.Node.Checked)
			{
				$SelectedObject.Add([pscustomobject]@{
						Name   = $_.Node.Text
						DistinguishedName = $_.Node.Name
					})
			}
			else
			{
				$DN = $_.Node.Name
				$SelectedObject | %{
					If ($_.DistinguishedName -eq $DN)
					{
						$Remove = $_
					}
				}
				$SelectedObject.Remove($Remove)
			}
		}
		
		#endregion Script
		
		#region Events
		
		$Form_StateCorrection_Load =
		{
			#Correct the initial state of the form to prevent the .Net maximized form issue
			$formChooseOU.WindowState = $InitialFormWindowState
		}
		
		$Form_Cleanup_FormClosed =
		{
			#Remove all event handlers from the controls
			try
			{
				$cb_AdvancedFeatures.remove_CheckedChanged($cb_AdvancedFeatures_CheckedChanged)
				$Treeview.remove_AfterLabelEdit($CreateOU)
				$Treeview.remove_BeforeCheck($Treeview_BeforeCheck)
				$Treeview.remove_AfterCheck($Treeview_AfterCheck)
				$Treeview.remove_BeforeExpand($Treeview_BeforeExpand)
				$Treeview.remove_NodeMouseClick($Treeview_NodeMouseClick)
				$Treeview.remove_DoubleClick($Treeview_DoubleClick)
				$buttonOK.remove_Click($buttonOK_Click)
				$formChooseOU.remove_Load($FormEvent_Load)
				$formChooseOU.remove_Shown($formChooseOU_Shown)
				$changeDomainToolStripMenuItem.remove_Click($changeDomainToolStripMenuItem_Click)
				$newOUToolStripMenuItem.remove_Click($newOUToolStripMenuItem_Click)
				$formChooseOU.remove_Load($Form_StateCorrection_Load)
				$formChooseOU.remove_FormClosed($Form_Cleanup_FormClosed)
			}
			catch [Exception]
			{ }
		}
		#endregion Events
		
		#region Form Code
		
		#
		# formChooseOU
		#
		$formChooseOU.Controls.Add($cb_AdvancedFeatures)
		$formChooseOU.Controls.Add($Treeview)
		$formChooseOU.Controls.Add($buttonOK)
		$formChooseOU.AcceptButton = $buttonOK
		$formChooseOU.ClientSize = '342, 535'
		$formChooseOU.FormBorderStyle = 'FixedDialog'
		#region Binary Data
		$formChooseOU.Icon = [System.Convert]::FromBase64String('
AAABAAkAICAQAAEABADoAgAAlgAAABgYEAABAAQA6AEAAH4DAAAQEBAAAQAEACgBAABmBQAAICAA
AAEACACoCAAAjgYAABgYAAABAAgAyAYAADYPAAAQEAAAAQAIAGgFAAD+FQAAICAAAAEAIACoEAAA
ZhsAABgYAAABACAAiAkAAA4sAAAQEAAAAQAgAGgEAACWNQAAKAAAACAAAABAAAAAAQAEAAAAAAAA
AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAIAAAACAgACAAAAAgACAAICAAACAgIAAwMDAAAAA
/wAA/wAAAP//AP8AAAD/AP8A//8AAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAiIAAAAAAAAAAAAAAAACIiIiHMAAAAAAAAAAAAAiI//iIiHcAAAAAAAAAAIiP//+IiIiH
dwAAAAAAiI//////iIiIiHhwAAAAAIj///////iIiIiHeHAAAACIj////4iIiIiIiIiHgAAAiIj/
iIiIiIj/iIiHeIcAAIiIiIiIiIiIiP+IiIeIcACIiHd3d3d3eIeI+IiHeIhwczMRMzd3czeIeI/4
iIiIcAczN3iIiIczeId4j4iHiHAACIiP///4i7OIh4iPiHiAAAAIiI//iIu7M4h3iP+HcAAAAAiI
iIi7u7u3iHiIiHAAAAAACIeP///4i7iHeIgAAAAAAAAAiI+IiLu7t3AAAAAAAAAAAACDMzMzMzM3
AAAAAAAAAAAAAAAAAAAACIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////////////////////////////////
///////8f///wB///gAP//AAA/8AAAH/AAAAfwAAAB8AAAAPAAAABwAAAAEAAAABgAAAAeAAAAH4
AAAB/gAAAf+AAAP/8AAf//wAD////+f/////////////////////KAAAABgAAAAwAAAAAQAEAAAA
AAAgAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAIAAAACAgACAAAAAgACAAICAAACAgIAAwMDA
AAAA/wAA/wAAAP//AP8AAAD/AP8A//8AAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIiIAAAAAAAA
AAAIiIiIcAAAAAAAAIiI/4iIhwAAAAAIiP//+IiIh3gAAACI/////4iHiHeAAACIj//4iIiIeIiI
AACIiIiIiIiPiIh4iACIiId4iIiI+IiHiHCHczMzd3eIiPiHeIeDAzd4h3M3iI+Id4gAiIj//4iz
eIiPh4gAAIiIiIu7M3iIiHcAAACIiIiIizeIiIcAAAAAiI//iLt3gAAAAAAAAIhzMzMzMAAAAAAA
AAAAAAAAdwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD/
w/8A/gH/APAA/wCAAD8AAAAfAAAADwAAAAMAAAABAAAAAAAAAAAAwAAAAPAAAAD8AAAA/wAHAP/A
BwD///MA////AP///wAoAAAAEAAAACAAAAABAAQAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAgAAAgAAAAICAAIAAAACAAIAAgIAAAICAgADAwMAAAAD/AAD/AAAA//8A/wAAAP8A/wD//wAA
////AAAzMzMzMzMAAHd3d3MzMwAAd3d3cz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X/suz0/6no8v+f5fD/luHu/4zd7f+C2uv/edbp/3DT6P9o0Ob/M6LF/wAA
AAAAAAAAAAAAAAAAAACFzuT/u+/1/7Ls9P+p6PL/n+Xw/5bh7v+M3e3/gtrr/3nW6f9w0+j/aNDm
/zOixf8AAAAAAAAAAAAAAAAAAAAAhc7k/7vv9f+y7PT/qejy/5/l8P+W4e7/jN3t/4La6/951un/
cNPo/2jQ5v8zosX/AAAAAAAAAAAAAAAAAAAAAIXO5P+77/X/mdPj/4bM3/92xdv/Z7/X/1m50/9Q
tNH/R7DO/0Gsy/9o0Ob/M6LF/wAAAAAAAAAAAAAAAAAAAACFzuT/u+/1/5/V5f/s////4v///9n/
///P////xf///7z///9Drcz/aNDm/zOixf8AAAAAAAAAAAAAAAAAAAAAhc7k/7vv9f+k2Of/7P//
/+L////Z////z////8X///+8////Ra/N/2jQ5v8zosX/AAAAAAAAAAAAAAAAAAAAAIXO5P+77/X/
qtvo/+z////i////2f///8/////F////vP///0awzv9o0Ob/M6LF/wAAAAAAAAAAAAAAAAAAAACF
zuT/u+/1/6/d6v+b1uX/iM/h/3fI3f9owtn/W7zV/1G20v9Jss//aNDm/zOixf8AAAAAAAAAAAAA
AAAAAAAAQouh/3issv9vqbH/ZqWv/1yirf9Tnqv/SZqq/z+XqP82k6b/LZCl/yWNo/8AX4L/AAAA
AAAAAAAAAAAAAAAAAEKLof9Ci6H/Qouh/0KLof9Ci6H/Qouh/0KLof9Ci6H/Qouh/0KLof9Ci6H/
Qouh/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAMADAADAAwAAwAMAAMADAADAAwAAwAMAAMADAADAAwAAwAMAAMAD
AADAAwAAwAMAAMADAADAAwAAwAMAAP//AAA=')
		#endregion
		$formChooseOU.MaximizeBox = $False
		$formChooseOU.MinimizeBox = $False
		$formChooseOU.Name = "formChooseOU"
		$formChooseOU.StartPosition = 'CenterParent'
		$formChooseOU.Text = "Choose Active Directory OU"
		$formChooseOU.add_Load($FormEvent_Load)
		$formChooseOU.add_Shown($formChooseOU_Shown)
		#
		# cb_AdvancedFeatures
		#
		$cb_AdvancedFeatures.Location = '19, 11'
		$cb_AdvancedFeatures.Name = "cb_AdvancedFeatures"
		$cb_AdvancedFeatures.Size = '137, 24'
		$cb_AdvancedFeatures.TabIndex = 3
		$cb_AdvancedFeatures.Text = "Advanced Features"
		$cb_AdvancedFeatures.UseVisualStyleBackColor = $True
		$cb_AdvancedFeatures.add_CheckedChanged($cb_AdvancedFeatures_CheckedChanged)
		#
		# Treeview
		#
		$Treeview.Anchor = 'Top, Bottom, Left, Right'
		$Treeview.ImageIndex = 1
		$Treeview.ImageList = $imagelist
		$Treeview.Location = '19, 37'
		$Treeview.Name = "Treeview"
		$System_Windows_Forms_TreeNode_1 = New-Object 'System.Windows.Forms.TreeNode' ("Active Directory Hierarchy", 1, 1)
		$System_Windows_Forms_TreeNode_1.ImageIndex = 1
		$System_Windows_Forms_TreeNode_1.Name = "Active Directory Hierarchy"
		$System_Windows_Forms_TreeNode_1.SelectedImageIndex = 1
		$System_Windows_Forms_TreeNode_1.Tag = "root"
		$System_Windows_Forms_TreeNode_1.Text = "Active Directory Hierarchy"
		[void]$Treeview.Nodes.Add($System_Windows_Forms_TreeNode_1)
		$Treeview.SelectedImageIndex = 1
		$Treeview.Size = '301, 442'
		$Treeview.TabIndex = 1
		$Treeview.add_AfterLabelEdit($CreateOU)
		$Treeview.add_BeforeCheck($Treeview_BeforeCheck)
		$Treeview.add_AfterCheck($Treeview_AfterCheck)
		$Treeview.add_BeforeExpand($Treeview_BeforeExpand)
		$Treeview.add_NodeMouseClick($Treeview_NodeMouseClick)
		$Treeview.add_DoubleClick($Treeview_DoubleClick)
		#
		# buttonOK
		#
		$buttonOK.Anchor = 'Bottom, Right'
		$buttonOK.DialogResult = 'OK'
		$buttonOK.Location = '245, 500'
		$buttonOK.Name = "buttonOK"
		$buttonOK.Size = '75, 23'
		$buttonOK.TabIndex = 0
		$buttonOK.Text = "OK"
		$buttonOK.UseVisualStyleBackColor = $True
		$buttonOK.add_Click($buttonOK_Click)
		#
		# imagelist
		#
		$Formatter_binaryFomatter = New-Object System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
		#region Binary Data
		$System_IO_MemoryStream = New-Object System.IO.MemoryStream ( ,[byte[]][System.Convert]::FromBase64String('
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAu
MC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAA
ACZTeXN0ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkD
AAAADwMAAABwCgAAAk1TRnQBSQFMAgEBBAEAAWABAAFgAQABEAEAARABAAT/AQkBAAj/AUIBTQE2
AQQGAAE2AQQCAAEoAwABQAMAASADAAEBAQABCAYAAQgYAAGAAgABgAMAAoABAAGAAwABgAEAAYAB
AAKAAgADwAEAAcAB3AHAAQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEA
AykBAANVAQADTQEAA0IBAAM5AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8B
AAHWAucBAAGQAakBrQIAAf8BMwMAAWYDAAGZAwABzAIAATMDAAIzAgABMwFmAgABMwGZAgABMwHM
AgABMwH/AgABZgMAAWYBMwIAAmYCAAFmAZkCAAFmAcwCAAFmAf8CAAGZAwABmQEzAgABmQFmAgAC
mQIAAZkBzAIAAZkB/wIAAcwDAAHMATMCAAHMAWYCAAHMAZkCAALMAgABzAH/AgAB/wFmAgAB/wGZ
AgAB/wHMAQABMwH/AgAB/wEAATMBAAEzAQABZgEAATMBAAGZAQABMwEAAcwBAAEzAQAB/wEAAf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1AXgB7wP3AewB9AH/AXkBoAGaAXkB
mQJ5AVEFmgF0Av8BeQGgC5oBdAP/AZkCGgGgBJoCegF5AVID/wEHA+8B9wHtAZgBeAGZAQcD7wHs
Av8BeQGgAZoCmQGgAXkBUgWaAXQC/wGZAaALmgF0A/8BmQIaAaAEmgJ6AXkBUgP/AbwD8wG8AZIB
BwHvAQcB8QLzAfIB7QL/AZkBoAGaAZkBeQGaAXkBUgWaAXQC/wGZAaALmgF0A/8BmQEaAZoCmQZ5
AVID/wG8AQcC7wH3A+0B7wIHAu8B7QL/AZkBoAGaAnkBdAJSBZoBdAL/AZkBwwaaAaAEmgF0A/8B
mQEaAZkDGgOaAVIBeQFSA/8CvAIHAvcCBwO8AgcBkgL/AZkBwwGaBHQBeQGgBJoBdAL/AZkBwwOa
AqABmQWaAXQD/wGZARoBmQL2BMMBUgF5AVID/wK8AesB7AIHAvMB8AG8Ae0BbQEHAfcC/wGZAcMD
mgKgAZkFmgF0Av8BmQWgAZoCdAV5A/8BmQIaAvYEwwFYAXkBUgP/AbwBBwKSAe8B9wKSAe8BvAHv
AZIB7wH3Av8BmQWgAZoCdAV5Av8BeQGaBBoBdAOaApkBmgF5A/8BmQMaApkDeQFYAXkBUgP/A/QB
8gG8AfECvAHvAfAE9AL/AZkBmgQaAXQDmgKZAZoBeQL/AZkGeQGaAvYB1gG0AZoBeQP/AVEBHAF5
A3QBUgRRASoG/wH0AbwB9wESAewB7wHwBv8BGwZ5AZoC9gHWAbQBmgGZCP8BmgZ5AZoD/wxRBv8B
9AG8AQcC7wH3AfEM/wHDBnkBw0H/AUIBTQE+BwABPgMAASgDAAFAAwABIAMAAQEBAAEBBgABARYA
A///AAIACw=='))
		#endregion
		$imagelist.ImageStream = $Formatter_binaryFomatter.Deserialize($System_IO_MemoryStream)
		$Formatter_binaryFomatter = $null
		$System_IO_MemoryStream = $null
		$imagelist.TransparentColor = 'Transparent'
		#
		# ContextMenu
		#
		[void]$ContextMenu.Items.Add($changeDomainToolStripMenuItem)
		[void]$ContextMenu.Items.Add($newOUToolStripMenuItem)
		$ContextMenu.Name = "ContextMenu"
		$ContextMenu.Size = '170, 26'
		#
		# changeDomainToolStripMenuItem
		#
		$changeDomainToolStripMenuItem.Name = "changeDomainToolStripMenuItem"
		$changeDomainToolStripMenuItem.Size = '169, 22'
		$changeDomainToolStripMenuItem.Text = "Change Domain..."
		$changeDomainToolStripMenuItem.add_Click($changeDomainToolStripMenuItem_Click)
		#
		# newOUToolStripMenuItem
		#
		$newOUToolStripMenuItem.Name = "newOUToolStripMenuItem"
		$newOUToolStripMenuItem.Size = '203, 22'
		$newOUToolStripMenuItem.Text = "New Organizational Unit"
		$newOUToolStripMenuItem.add_Click($newOUToolStripMenuItem_Click)
		#endregion Form Code
		
		#Save the initial state of the form
		$InitialFormWindowState = $formChooseOU.WindowState
		#Init the OnLoad event to correct the initial state of the form
		$formChooseOU.add_Load($Form_StateCorrection_Load)
		#Clean up the control events
		$formChooseOU.add_FormClosed($Form_Cleanup_FormClosed)
		#Show the Form
		$formChooseOU.ShowDialog() | Out-Null
		return $SelectedObject
		
	} #End Function Choose-ADOrganizationalUnit
	$comboboxdeploytype_TextChanged={
		#TODO: Place custom script here
		Update-NavButtons
	}
	
	$richtextboxStatus_TextChanged={
		#TODO: Place custom script here
		Update-NavButtons
	}
	
	# --End User Generated Script--
	#----------------------------------------------
	#region Generated Events
	#----------------------------------------------
	
	$Form_StateCorrection_Load=
	{
		#Correct the initial state of the form to prevent the .Net maximized form issue
		$formKURZDeploymentTool.WindowState = $InitialFormWindowState
	}
	
	$Form_Cleanup_FormClosed=
	{
		#Remove all event handlers from the controls
		try
		{
			$richtextboxStatus.remove_TextChanged($richtextboxStatus_TextChanged)
			$buttonBack.remove_Click($buttonBack_Click)
			$buttonFinish.remove_Click($buttonFinish_Click)
			$textboxInOU.remove_TextChanged($textboxinOU_TextChanged)
			$textboxInOU.remove_Enter($textboxinOu_enter)
			$textboxInstallName.remove_TextChanged($textboxInstallName_TextChanged)
			$textboxUninstallName.remove_TextChanged($textboxUninstallName_TextChanged)
			$textboxUnOU.remove_TextChanged($textboxUnOU_TextChanged)
			$textboxUnOU.remove_Enter($textboxunOu_enter)
			$comboboxdeploytype.remove_TextChanged($comboboxdeploytype_TextChanged)
			$textboxAppName.remove_TextChanged($textboxappName_TextChanged)
			$textboxAppName.remove_Enter($textboxAppName_Enter)
			$tabcontrolWizard.remove_Selecting($tabcontrolWizard_Selecting)
			$tabcontrolWizard.remove_Deselecting($tabcontrolWizard_Deselecting)
			$buttonNext.remove_Click($buttonNext_Click)
			$formKURZDeploymentTool.remove_Load($formKURZDeploymentTool_Load)
			$openfiledialog1.remove_FileOk($openfiledialog1_FileOk)
			$formKURZDeploymentTool.remove_Load($Form_StateCorrection_Load)
			$formKURZDeploymentTool.remove_FormClosed($Form_Cleanup_FormClosed)
		}
		catch { Out-Null <# Prevent PSScriptAnalyzer warning #> }
	}
	#endregion Generated Events

	#----------------------------------------------
	#region Generated Form Code
	#----------------------------------------------
	$formKURZDeploymentTool.SuspendLayout()
	$trackbar1.BeginInit()
	$tabcontrolWizard.SuspendLayout()
	$tabpageStep1.SuspendLayout()
	$ADGroup.SuspendLayout()
	$groupbox6.SuspendLayout()
	$tabpageStep2.SuspendLayout()
	$groupbox2.SuspendLayout()
	#
	# formKURZDeploymentTool
	#
	$formKURZDeploymentTool.Controls.Add($textboxstat)
	$formKURZDeploymentTool.Controls.Add($trackbar1)
	$formKURZDeploymentTool.Controls.Add($richtextboxStatus)
	$formKURZDeploymentTool.Controls.Add($buttonCancel)
	$formKURZDeploymentTool.Controls.Add($buttonBack)
	$formKURZDeploymentTool.Controls.Add($buttonFinish)
	$formKURZDeploymentTool.Controls.Add($tabcontrolWizard)
	$formKURZDeploymentTool.Controls.Add($buttonNext)
	$formKURZDeploymentTool.AcceptButton = $buttonFinish
	$formKURZDeploymentTool.AutoScaleDimensions = '6, 13'
	$formKURZDeploymentTool.AutoScaleMode = 'Font'
	$formKURZDeploymentTool.CancelButton = $buttonCancel
	$formKURZDeploymentTool.ClientSize = '718, 645'
	$formKURZDeploymentTool.FormBorderStyle = 'FixedDialog'
	$formKURZDeploymentTool.MaximizeBox = $False
	$formKURZDeploymentTool.Name = 'formKURZDeploymentTool'
	$formKURZDeploymentTool.StartPosition = 'CenterScreen'
	$formKURZDeploymentTool.Text = 'KURZ Deployment Tool'
	$formKURZDeploymentTool.add_Load($formKURZDeploymentTool_Load)
	#
	# textboxstat
	#
	$textboxstat.Location = '144, 610'
	$textboxstat.Name = 'textboxstat'
	$textboxstat.Size = '319, 20'
	$textboxstat.TabIndex = 20
	#
	# trackbar1
	#
	$trackbar1.Location = '-97, -36'
	$trackbar1.Name = 'trackbar1'
	$trackbar1.Size = '104, 45'
	$trackbar1.TabIndex = 19
	#
	# richtextboxStatus
	#
	$richtextboxStatus.Location = '94, 610'
	$richtextboxStatus.Name = 'richtextboxStatus'
	$richtextboxStatus.Size = '35, 23'
	$richtextboxStatus.TabIndex = 18
	$richtextboxStatus.Text = ''
	$richtextboxStatus.add_TextChanged($richtextboxStatus_TextChanged)
	#
	# buttonCancel
	#
	$buttonCancel.Anchor = 'Bottom, Right'
	$buttonCancel.DialogResult = 'Cancel'
	$buttonCancel.Location = '550, 610'
	$buttonCancel.Name = 'buttonCancel'
	$buttonCancel.Size = '75, 23'
	$buttonCancel.TabIndex = 4
	$buttonCancel.Text = '&Cancel'
	$buttonCancel.UseCompatibleTextRendering = $True
	$buttonCancel.UseVisualStyleBackColor = $True
	#
	# buttonBack
	#
	$buttonBack.Anchor = 'Bottom, Left'
	$buttonBack.Location = '13, 610'
	$buttonBack.Name = 'buttonBack'
	$buttonBack.Size = '75, 23'
	$buttonBack.TabIndex = 1
	$buttonBack.Text = '< &Back'
	$buttonBack.UseCompatibleTextRendering = $True
	$buttonBack.UseVisualStyleBackColor = $True
	$buttonBack.add_Click($buttonBack_Click)
	#
	# buttonFinish
	#
	$buttonFinish.Anchor = 'Bottom, Right'
	$buttonFinish.DialogResult = 'OK'
	$buttonFinish.Location = '631, 610'
	$buttonFinish.Name = 'buttonFinish'
	$buttonFinish.Size = '75, 23'
	$buttonFinish.TabIndex = 3
	$buttonFinish.Text = '&Finish'
	$buttonFinish.UseCompatibleTextRendering = $True
	$buttonFinish.UseVisualStyleBackColor = $True
	$buttonFinish.add_Click($buttonFinish_Click)
	#
	# tabcontrolWizard
	#
	$tabcontrolWizard.Controls.Add($tabpageStep1)
	$tabcontrolWizard.Controls.Add($tabpageStep2)
	$tabcontrolWizard.Anchor = 'Top, Bottom, Left, Right'
	$tabcontrolWizard.Location = '13, 12'
	$tabcontrolWizard.Name = 'tabcontrolWizard'
	$tabcontrolWizard.SelectedIndex = 0
	$tabcontrolWizard.Size = '693, 592'
	$tabcontrolWizard.TabIndex = 0
	$tabcontrolWizard.add_Selecting($tabcontrolWizard_Selecting)
	$tabcontrolWizard.add_Deselecting($tabcontrolWizard_Deselecting)
	#
	# tabpageStep1
	#
	$tabpageStep1.Controls.Add($labelOU)
	$tabpageStep1.Controls.Add($textboxInOU)
	$tabpageStep1.Controls.Add($textboxInstallName)
	$tabpageStep1.Controls.Add($labelName)
	$tabpageStep1.Controls.Add($ADGroup)
	$tabpageStep1.Location = '4, 22'
	$tabpageStep1.Name = 'tabpageStep1'
	$tabpageStep1.Padding = '3, 3, 3, 3'
	$tabpageStep1.Size = '685, 566'
	$tabpageStep1.TabIndex = 0
	$tabpageStep1.Text = 'Step 1'
	$tabpageStep1.UseVisualStyleBackColor = $True
	#
	# labelOU
	#
	$labelOU.AutoSize = $True
	$labelOU.Location = '12, 94'
	$labelOU.Name = 'labelOU'
	$labelOU.Size = '24, 17'
	$labelOU.TabIndex = 6
	$labelOU.Text = 'OU:'
	$labelOU.UseCompatibleTextRendering = $True
	#
	# textboxInOU
	#
	$textboxInOU.Location = '93, 87'
	$textboxInOU.Name = 'textboxInOU'
	$textboxInOU.Size = '259, 20'
	$textboxInOU.TabIndex = 2
	$textboxInOU.add_TextChanged($textboxinOU_TextChanged)
	$textboxInOU.add_Enter($textboxinOu_enter)
	#
	# textboxInstallName
	#
	$textboxInstallName.Location = '93, 61'
	$textboxInstallName.Name = 'textboxInstallName'
	$textboxInstallName.Size = '259, 20'
	$textboxInstallName.TabIndex = 1
	$textboxInstallName.add_TextChanged($textboxInstallName_TextChanged)
	#
	# labelName
	#
	$labelName.AutoSize = $True
	$labelName.Location = '12, 64'
	$labelName.Name = 'labelName'
	$labelName.Size = '38, 17'
	$labelName.TabIndex = 0
	$labelName.Text = 'Name:'
	$labelName.UseCompatibleTextRendering = $True
	#
	# ADGroup
	#
	$ADGroup.Controls.Add($groupbox6)
	$ADGroup.Controls.Add($groupbox5)
	$ADGroup.Location = '4, 19'
	$ADGroup.Name = 'ADGroup'
	$ADGroup.Size = '675, 547'
	$ADGroup.TabIndex = 10
	$ADGroup.TabStop = $False
	$ADGroup.Text = 'AD-Group:'
	$ADGroup.UseCompatibleTextRendering = $True
	#
	# groupbox6
	#
	$groupbox6.Controls.Add($labelLanguage)
	$groupbox6.Controls.Add($textboxUninstallName)
	$groupbox6.Controls.Add($labelAppName)
	$groupbox6.Controls.Add($textboxUnOU)
	$groupbox6.Location = '5, 124'
	$groupbox6.Name = 'groupbox6'
	$groupbox6.Size = '363, 139'
	$groupbox6.TabIndex = 10
	$groupbox6.TabStop = $False
	$groupbox6.Text = 'Uninstall:'
	$groupbox6.UseCompatibleTextRendering = $True
	#
	# labelLanguage
	#
	$labelLanguage.AutoSize = $True
	$labelLanguage.Location = '3, 52'
	$labelLanguage.Name = 'labelLanguage'
	$labelLanguage.Size = '24, 17'
	$labelLanguage.TabIndex = 8
	$labelLanguage.Text = 'OU:'
	$labelLanguage.UseCompatibleTextRendering = $True
	#
	# textboxUninstallName
	#
	$textboxUninstallName.Location = '84, 19'
	$textboxUninstallName.Name = 'textboxUninstallName'
	$textboxUninstallName.Size = '259, 20'
	$textboxUninstallName.TabIndex = 3
	$textboxUninstallName.add_TextChanged($textboxUninstallName_TextChanged)
	#
	# labelAppName
	#
	$labelAppName.AutoSize = $True
	$labelAppName.Location = '3, 26'
	$labelAppName.Name = 'labelAppName'
	$labelAppName.Size = '38, 17'
	$labelAppName.TabIndex = 7
	$labelAppName.Text = 'Name:'
	$labelAppName.UseCompatibleTextRendering = $True
	#
	# textboxUnOU
	#
	$textboxUnOU.Location = '84, 45'
	$textboxUnOU.Name = 'textboxUnOU'
	$textboxUnOU.Size = '259, 20'
	$textboxUnOU.TabIndex = 4
	$textboxUnOU.add_TextChanged($textboxUnOU_TextChanged)
	$textboxUnOU.add_Enter($textboxunOu_enter)
	#
	# groupbox5
	#
	$groupbox5.Location = '5, 19'
	$groupbox5.Name = 'groupbox5'
	$groupbox5.Size = '364, 99'
	$groupbox5.TabIndex = 9
	$groupbox5.TabStop = $False
	$groupbox5.Text = 'Install:'
	$groupbox5.UseCompatibleTextRendering = $True
	#
	# tabpageStep2
	#
	$tabpageStep2.Controls.Add($progressbar1)
	$tabpageStep2.Controls.Add($labelDeploymentType)
	$tabpageStep2.Controls.Add($groupbox2)
	$tabpageStep2.Location = '4, 22'
	$tabpageStep2.Name = 'tabpageStep2'
	$tabpageStep2.Padding = '3, 3, 3, 3'
	$tabpageStep2.Size = '685, 566'
	$tabpageStep2.TabIndex = 1
	$tabpageStep2.Text = 'Step 2'
	$tabpageStep2.UseVisualStyleBackColor = $True
	#
	# progressbar1
	#
	$progressbar1.Location = '8, 454'
	$progressbar1.Name = 'progressbar1'
	$progressbar1.Size = '671, 23'
	$progressbar1.TabIndex = 18
	#
	# labelDeploymentType
	#
	$labelDeploymentType.AutoSize = $True
	$labelDeploymentType.Location = '6, 84'
	$labelDeploymentType.Name = 'labelDeploymentType'
	$labelDeploymentType.Size = '96, 17'
	$labelDeploymentType.TabIndex = 4
	$labelDeploymentType.Text = 'Deployment Type:'
	$labelDeploymentType.UseCompatibleTextRendering = $True
	#
	# groupbox2
	#
	$groupbox2.Controls.Add($datetimestart)
	$groupbox2.Controls.Add($labelDeploymentStarttime)
	$groupbox2.Controls.Add($comboboxdeploytype)
	$groupbox2.Controls.Add($labelApplicationName)
	$groupbox2.Controls.Add($textboxAppName)
	$groupbox2.Location = '6, 18'
	$groupbox2.Name = 'groupbox2'
	$groupbox2.Size = '653, 192'
	$groupbox2.TabIndex = 17
	$groupbox2.TabStop = $False
	$groupbox2.Text = 'Deployment:'
	$groupbox2.UseCompatibleTextRendering = $True
	#
	# datetimestart
	#
	$datetimestart.Location = '120, 107'
	$datetimestart.Name = 'datetimestart'
	$datetimestart.Size = '121, 20'
	$datetimestart.TabIndex = 19
	#
	# labelDeploymentStarttime
	#
	$labelDeploymentStarttime.AutoSize = $True
	$labelDeploymentStarttime.Location = '0, 113'
	$labelDeploymentStarttime.Name = 'labelDeploymentStarttime'
	$labelDeploymentStarttime.Size = '116, 17'
	$labelDeploymentStarttime.TabIndex = 18
	$labelDeploymentStarttime.Text = 'Deployment Starttime:'
	$labelDeploymentStarttime.UseCompatibleTextRendering = $True
	#
	# comboboxdeploytype
	#
	$comboboxdeploytype.FormattingEnabled = $True
	[void]$comboboxdeploytype.Items.Add('Available')
	[void]$comboboxdeploytype.Items.Add('Required')
	$comboboxdeploytype.Location = '120, 66'
	$comboboxdeploytype.Name = 'comboboxdeploytype'
	$comboboxdeploytype.Size = '121, 21'
	$comboboxdeploytype.TabIndex = 4
	$comboboxdeploytype.add_TextChanged($comboboxdeploytype_TextChanged)
	#
	# labelApplicationName
	#
	$labelApplicationName.AutoSize = $True
	$labelApplicationName.Location = '2, 24'
	$labelApplicationName.Name = 'labelApplicationName'
	$labelApplicationName.Size = '97, 17'
	$labelApplicationName.TabIndex = 2
	$labelApplicationName.Text = 'Application-Name:'
	$labelApplicationName.UseCompatibleTextRendering = $True
	#
	# textboxAppName
	#
	$textboxAppName.Location = '120, 21'
	$textboxAppName.Name = 'textboxAppName'
	$textboxAppName.Size = '224, 20'
	$textboxAppName.TabIndex = 3
	$textboxAppName.add_TextChanged($textboxappName_TextChanged)
	$textboxAppName.add_Enter($textboxAppName_Enter)
	#
	# buttonNext
	#
	$buttonNext.Anchor = 'Bottom, Right'
	$buttonNext.Location = '469, 610'
	$buttonNext.Name = 'buttonNext'
	$buttonNext.Size = '75, 23'
	$buttonNext.TabIndex = 2
	$buttonNext.Text = '&Next >'
	$buttonNext.UseCompatibleTextRendering = $True
	$buttonNext.UseVisualStyleBackColor = $True
	$buttonNext.add_Click($buttonNext_Click)
	#
	# openfiledialog1
	#
	$openfiledialog1.FileName = 'openfiledialog1'
	$openfiledialog1.add_FileOk($openfiledialog1_FileOk)
	#
	# colordialog1
	#
	#
	# errorprovider1
	#
	$errorprovider1.ContainerControl = $formKURZDeploymentTool
	$groupbox2.ResumeLayout()
	$tabpageStep2.ResumeLayout()
	$groupbox6.ResumeLayout()
	$ADGroup.ResumeLayout()
	$tabpageStep1.ResumeLayout()
	$tabcontrolWizard.ResumeLayout()
	$trackbar1.EndInit()
	$formKURZDeploymentTool.ResumeLayout()
	#endregion Generated Form Code

	#----------------------------------------------

	#Save the initial state of the form
	$InitialFormWindowState = $formKURZDeploymentTool.WindowState
	#Init the OnLoad event to correct the initial state of the form
	$formKURZDeploymentTool.add_Load($Form_StateCorrection_Load)
	#Clean up the control events
	$formKURZDeploymentTool.add_FormClosed($Form_Cleanup_FormClosed)
	#Show the Form
	return $formKURZDeploymentTool.ShowDialog()

} #End Function

#Call the form
Show-appdeployapplication_psf | Out-Null

For the XML-File:


<?xml version="1.0"?>
<MP>
<Name>Sccmservername.domain</Name>
<Code>PS1:\</Code>
<module>C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1</module>
<domainname>AD-Domainname</domainname>
</MP>

Copy troubleshooting logs via “run a Script” ConfigMgr 1706

Target: Copy logs to troubleshoot OS-Deployments and Software-Deployments via “run a Script” in ConfigMgr 1706

With the release of ConfigMgr 1706 the feature to run Powershell Scripts was released. Sometimes it can be helpful to copy some logs to troubleshoot the OS-Deployment process or a Software-Deployment process. I created a small script which copys the smsts.log and some of the for me intressing Software-Deployment logs.

First step: create a network share and give everyone full-access.

Afterwards you can go in ConfigMgr to the Scripts section and create your script:

Script-Content:

pushd \\server\smstslogs$

new-item $env:computername -ItemType directory -Force

cd $env:COMPUTERNAME

Copy-Item $env:windir\CCM\Logs\smsts* -Force

Copy-Item $env:windir\CCM\Logs\app* -Force

Copy-Item $env:windir\ccmsetup\Logs\ccmsetup* -Force

Copy-Item $env:windir\Logs\Software\* -Force

Save the script – and approve it afterwards:

Then you can run the script against any collection you need / select the collection and select “Run Script”

Select your script and run it against your collection:

The result will look the following / on your network share you will find for each device which is online a new folder and the logs included:

Done!

Create Softwarecenter Shortcut in Start Menu via Configmgr

Target: Create Softwarecenter shortcut in start menu for all users and deploy it via Configmgr package

In my previous post I discripted howto create shortcuts in start menu and in the taskbar via Configmgr. In this post I’ll show you an example to create in Windows 10 start menu a shorcut to the softwarecenter of Configmgr.

You can download the package sources from the following link:

https://www.file-upload.net/download-12690011/softwarecenter_shortcut.zip.html

The package includes the Pinto10v2.exe and the powershell script to create the shortcut.

1

Source-Code of the .ps1:

#create shortcut and pinto Start-menu on Windows 10

.\PinTo10v2.exe /pinsm “$env:Homedrive\Windows\CCM\SCClient.exe”

#Rename the Shortcut

Get-ItemProperty “$env:Homedrive\Users\$env:USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\SCClient.lnk” | Rename-Item -NewName {$_.name -replace “SCClient”,”Softwarecenter”} -PassThru

Howto deploy the package.

Create a new package:

2

With a program – as command line use the .ps1 file. Run the program with user rights:

3

In the first test you can set the visibility to “Normal” for production deployments set it to Hidden:

4

Limit the package to Win10:

5

Distribute the package to the required Distribution-Points. And deploy it the the required collection.

The result will look like below.

Before the script runs:

6

Afterwards:

7

Create shortcuts in taskbar and start menu on Windows 10 via ConfigMgr

Target: Easily create shortcuts in taskbar and start menu on Windows 10 Professional

I wanted to create a few shortcuts in the taskbar and in the start menu on a few Windows 10 Professional devices.

As we cannot manage the shortcuts with the Windows 10 Professional version – I searched for a solution to manage it via an ConfigMgr package. I found a version of the already known PinTo application which had worked in Windows 7. The new version v2 works also in Windows 10 and the handling is realy easy.

The Sources for the Pinto10v2.exe can be downloaded here / created by Stuart Pearson:

https://www.dropbox.com/s/q4joxy231hz0klj/PinTo10v2_1.1.zip?dl=1

The program is very easy to use - see the syntax below:

Syntax: PinTo10v2 [/pintb | /unpintb | /pinsm | /unpinsm] 'filename'

pintb   = Pin to the Task Bar

unpintb = Unpin from the Task Bar

pinsm   = Pin to the Start Menu

unpinsm = Unpin from the Start Menu

Examples:

Pin powershell.exe to taskbar:

PinTo10v2.exe /pinsm "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"

Unpin powershell.exe from taskbar:

PinTo10v2.exe /pintb "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"

Pin powershell.exe to start menu:

PinTo10v2.exe /pinsm "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"

Unpin powershell.exe to start menu:

PinTo10v2.exe /pinsm "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"

In this post I’ll explain how to create a shortcut in the taskbar & start menu for Powershell and Internet Explorer.

First copy the PinTo10v2.exe in a folder and create a .cmd file with the required syntax of the Pinto10v2.exe:

1

2

Afterwards I created a package that runs in hidden mode:

3

Distribute the package afterwards to the required distribution-points. And deploy the package to the required collection.

In my case everything went smooth – start menu and taskbar before:

4

Start menu and taskbar afterwards:

5

The PinTo10v2.exe can also be used in powershell-script / for example in the App Deployment Toolkit.

Copy smsts.log automatically on a network share if error in OSD

Target: Copy the smsts.log to a network share during a task-sequence if there is any error in the task-sequence / except the option “Continue on error” is set.

Sometimes it can be hard if you request an smsts.log from a location where you don’t have real IT on side.
You need to know at which step the installation process stopped. During OSD, if the disk is already partitioned, within Windows or before, if it’s a x64 system or x86….

There is the possability to copy the logs automatically to a network share. I exported the example Task-Sequence which can be downloaded here: Download

You only need to copy the .zip file on an network share and import the task-sequence in the ConfigMgr Console.

The example Task-Sequence includes the following steps:

This will do the following if you have an error in the task-sequence.

On the file-share you will have a folder with the device name:

And inside the folder the smsts.log:

All steps more detailed:

In my productive TS all steps are one level / folder under the “Task Sequence” step:

Steps:

1. Log Capture:

Options of this step:

2. Connect to Network Folder / create a network-share before with everyone at least write access.

3. Create folder on the share for Computer

4. Copy the smsts.log to the share directory

5. Display a Popup that there was an error and you need to check the logs.

Error message during failure in OSD:

I found the source / Idea on the following Blog-Post: https://systemcenterguru.wordpress.com/2013/11/02/capturing-task-sequence-log-files-during-osd-deployment/

PowerBI SCCM Dashboard – Installation

Target: Create a simple SCCM Dashboard to view the Update-Compliance and Client-health.

Download the Dashboard from the following Link:

https://powerbi.microsoft.com/de-de/solution-templates/sccm/

This will guide you through the setup – you need to specify a user which has read access on the CM-Database and a destination SQL-Database / Azure. At the end you need to download the report:

1.png

To open the file you need to install the Power BI Desktop which is free:

https://powerbi.microsoft.com/de-de/desktop/

All you need to do than is to click on Refresh in the main menu. The report can than be published with the team if you have a PowerBI Pro license / 60 day free trial.

In my case everything went smooth – without any error – and the dashboard is realy good to detect if your clients are healhy:

23