Creating a Home Drive with Windows PowerShell

With the following script I will do 3 things:

1. Set the user his home folder with drive letter
2. Create a folder on your home folders file share
3. Giving users full control on there folder.

 

The Script:

Get-ADUser -Filter * -SearchBase “OU=wardusers,DC=wardvissers,DC=local” | Foreach-Object {
$sam = $_.SamAccountName
$sid = $_.Sid
$HomeDrive=’J:’
$Domain=wardvissers.local’
$UserRoot=’\\wardvissers.local\dfs\home\’
$HomeDir=$UserRoot+$sam

# Assign the Drive letter and Home Drive for the user in Active Directory

SET-ADUSER $sam –HomeDrive $HomeDrive –HomeDirectory $HomeDir

# Create the folder on the root of the common Users Share

NEW-ITEM –path $HomeDir -type directory -force

$account=$Domain+’\’+$Accountname

# Set parameters for Access rule

$rights=[System.Security.AccessControl.FileSystemRights]::FullControl
$inheritance=[System.Security.AccessControl.InheritanceFlags]”ContainerInherit,ObjectInherit”
$propagation=[System.Security.AccessControl.PropagationFlags]::None
$allowdeny=[System.Security.AccessControl.AccessControlType]::Allow
$dirACE=New-Object System.Security.AccessControl.FileSystemAccessRule ($sid,$rights,$inheritance,$propagation,$allowdeny)
$dirACL=Get-Acl $HomeDir

$dirACL.AddAccessRule($dirACE)

Set-Acl -path $HomeDir -AclObject $dirACL

Write-Host $HomeDir access rights assigned

}

Active Directory Accidental Deletion – Prevention

Accidental deletions in active directory can cause havoc and unfortunately. This may have been avoided and secondly could have been fixed in less than 10 % of the actual time spent if the environment was using one of the latest features that we included in Windows 2008 R2 ( Active Directory Recycle Bin ). Most critical situations arise due to accidental human /tool interference or configuration and it is important to be able to come out of such situations within minimal down time, Accidental Deletion in Active Directory is one such situation.

Powershell Enable Protected From Accidenta lDeletion:
Get-ADobject -Filter * -SearchBase “DC=wardvissers,DC=local” | Set-adobject -ProtectedFromAccidentalDeletion $true

Convert VHD to VHDX

VHDX is the new and default format of virtual hard disk (VDH) that is provided by Windows 8 Client Hyper-V and Windows Server 2012 Hyper-V. There are many reasons to favor VHDX files over VHD files, including:

  • scalability to 64 TB instead of 2040GB
  • better performance by offering 4 K sector matching
  • protection against data corruption during power outages
Using PowerShell to Convert to VHDX

You can dispense with the time-consuming wizard by using PowerShell. This will be extremely useful if you need to use a script to automate lots of VHD conversions across many virtual machines. The following snippet will convert a VHD to a VHDX:

Convert-VHD –Path d:\VM01\Disk0.vhd –DestinationPath d:\VM01\Disk0.vhdx

When you create a new VHDX file (not converted) it has a physical sector size of 4 K. A converted VHDX file has a physical sector size of 512 Bytes. You can change the physical sector size of a converted VHDX by running this piece of PowerShell before you power up the virtual machine:

set-vhd d:\VM01\Disk0.vhdx -PhysicalSectorSizeBytes 4096

Now you have a virtual machine that is using the best kind of virtual machine storage, the VHDX format virtual hard disk

The above instructions do not finish the job. The next essential set of steps are:

  1. Open the settings of the virtual machine.
  2. Replace the VHD with the VHDX.
  3. Start and test the virtual machine.
  4. Delete the VHD file.

Server 2012 Dedub

Start Windows PowerShell. Right-click the Windows PowerShell icon on the taskbar, and then click Run as Administrator.

Run the following Windows PowerShell commands:

PS C:\> Import-Module ServerManager
PS C:\> Add-WindowsFeature -name FS-Data-Deduplication
PS C:\> Import-Module Deduplication
PS C:\> Enable-DedupVolume E: & Enable-DedupVolume D:

And wait….

dedub

Saving already 240GB on my home lab…. Dedub is great

Publish Exchange 2013 With Forefront Threat Management Gateway

 

TMG doest not support jet Exchange 2013. But with minor changes you get it working Smile

Change in the OWA Rule

In Exchange 2013 changed the published server logoff URL to /owa/logoff.owa

image

You need create a Extra Rule Exchange 2013 APPS Rule

image
You need the ExchangeGuid

Powershell:

Get-Mailbox -Arbitration | where {$_.PersistedCapabilities -like “OrganizationCapabilityClientExtensions”} | fl exchangeGUID, primarysmtpaddress
ExchangeGuid : 3eccca51-d996-49df-b6e0-302d644fdcaa

image

image

image

 

Totally:
image

After configuring DirectAccess in an IPv4-only deployment with a single network adapter, and after the default DNS64 (the IPv6 address which contains ":3333::") is automatically configured on the network adapter, attempting to enable load-balancing via the Remote Access Management console causes a prompt for the user to supply an IPv6 DIP. If an IPv6 DIP is supplied, the configuration fails after clicking Commit with the error: The parameter is incorrect.

  1. Download the backup and restore scripts from Back up and Restore Remote Access Configuration.
  2. Back up your Remote Access GPOs using the downloaded script Backup-RemoteAccess.ps1
  3. Attempt to enable load balancing until the step at which it fails. On the Enable Load Balancing dialog box, expand the details area, right-click in the details area, and then click Copy Script.
  4. Open Notepad, and paste the contents of the clipboard. For example:

    Set-RemoteAccessLoadBalancer -InternetDedicatedIPAddress @(‘10.244.4.19/255.255.255.0′,’fdc4:29bd:abde:3333::2/128’) -InternetVirtualIPAddress @(‘fdc4:29bd:abde:3333::1/128’, ‘10.244.4.21/255.255.255.0’) -ComputerName ‘DA1.domain1.corp.contoso.com’ -Verbose

  5. Close any open Remote Access dialog boxes and close the Remote Access Management console.
  6. Edit the pasted text and remove the IPv6 addresses. For example:

    (Remove de IPv6 IP Addresses)
    Set-RemoteAccessLoadBalancer -InternetDedicatedIPAddress @(‘10.244.4.19/255.255.255.0’) -InternetVirtualIPAddress @(‘10.244.4.21/255.255.255.0’) -ComputerName ‘DA1.domain1.corp.contoso.com’ -Verbose

    In an elevated PowerShell window, run the command from the previous step.

  7. If the cmdlet fails while it is running (not due to incorrect input values), run the command Restore-RemoteAccess.ps1 and follow instructions to make sure that the integrity of your original configuration is maintained.
  8. You can now open the Remote Access Management console again.

Windows Server 2012: Convert server Core to server with a Gui

  1. Create a folder to mount a Windows Imaging File (WIM) in with the command mkdir c:\mountdir

  2. Determine the index number for a Server with a GUI image (for example, SERVERDATACENTER, not SERVERDATACENTERCORE) using this command at an elevated command prompt: Dism /get-wiminfo /wimfile:<drive>:sources\install.wim

  3. Mount the WIM file using this command at an elevated command prompt: Dism /mount-wim /WimFile:<drive>:\sources\install.wim /Index:<#_from_step_2> /MountDir:c:\mountdir /readonly

  4. Start Windows PowerShell and run this cmdlet:

    Install-WindowsFeature Server-Gui-Mgmt-Infra,Server-Gui-Shell –Restart –Source c:\mountdir\windows\winsxs

  5. Alternatively, if you want to use Windows Update as the source instead of a WIM file, use this Windows PowerShell cmdlet:

    Install-WindowsFeature Server-Gui-Mgmt-Infra,Server-Gui-Shell –Restart

Windows Server 2012: Convert a server with a Gui to Core with Windows PowerShell

To convert to a Server Core installation with Windows PowerShell: run the following cmdlet:
Uninstall-WindowsFeature Server-Gui-Mgmt-Infra -restart

FREE e-Book: The Hands-on Guide: Understanding Hyper-V in Windows Server 2012

The Hands-on Guide: Understanding Hyper-V in Windows Server 2012 gives you simple step-by-step instructions to help you perform Hyper-V-related tasks like a seasoned expert.

You will learn how to:

  • Build clustered Hyper-V deployment
  • Manage Hyper-V through PowerShell
  • Create virtual machine replicas
  • Transition from a legacy Hyper-V environment, and more

Download the first 5 chapters (180 Pages) today! Klik on the Picture to go to the Veeam Website 

image

Issue with Windows Management Framework 3.0 on Exchange 2007 and Exchange 2010

Recently, Windows Update began offering the Windows Management Framework 3.0 as an Optional update. This includes all forms of update distribution, such as Microsoft Update, WSUS, System Center Configuration Manager and other mechanisms. The key bit here is that the Windows Management Framework 3.0 includes PowerShell 3.0.

Windows Management Framework 3.0 is being distributed as KB2506146 and KB2506143 (which one is offered depends on which server version you are running – 2008 Sp2 or 2008 R2 Sp1).

What does that mean to you?

Windows Management Framework 3.0 (specifically PowerShell 3.0) is not yet supported on any version of Exchange except Exchange Server 2013 (which requires it). If you install Windows Management Framework 3.0 on a server running Exchange 2007 or Exchange 2010, you will encounter problems, such as Rollups that will not install, or the Exchange Management Shell may not run properly.

We have seen rollups not installing with the following symptoms:

  • If rollup is installed through Microsoft Update, the installation might error with error code of 80070643
  • If rollup is installed from a download, the error displayed is “Setup ended prematurely because of an error.”
  • In both cases, event log might show the error with an error code of “1603”

Exchange Team adviced that Windows Management Framework 3.0 should not be deployed on servers running Exchange 2007 or Exchange 2010, or on workstations with the Exchange Management Tools for either version installed. If you have already deployed this update, it should be removed. Once the update is removed, functionality should be restored.

Translate »