Posts Tagged ‘Powershell’

How to: View configured mailbox quota’s in Exchange 2010/2013 using Out-GridView

When you’ve configured mailbox quota’s within your Exchange 2010/2013 environment, you’ve to check the configuration sometimes. Using Microsoft PowerShell, you can watch the current configuration within a few second, so this is extremely powerfull!! But, when you have to query for some specific user or result, it’s not that easy.

There’s a very usefull command within PowerShell that I’m using almost for all my scripts….Out-GridView. When using the parameter Out-GridView, the results are not showing within the PowerShell screen, but in a separate window! Within this window, you can very easy add some search criteria….for example: specific user, quota or an overview per database.

One requirement is that the Windows Feature “Windows PowerShell Integrated Scripting Environment (ISE)” is installed on the Exchange servers or mangement server from where you’re running the commands.

1.) Open the Exchange Management Shell (EMS)
2.) For an overview of the current mailbox quota, use the following command.
Get-Mailbox -Identity mswinkels | ft Name, IssueWarningQuota, ProhibitSendQuota, ProhibitSendReceiveQuota
3.) The results of this command is shown within the PowerShell window
4.) Now we’re running the same command, but replace “ft” (format-table) with “select” and add the parameter “Out-GridView”
Get-Mailbox -Identity mswinkels | Select Name, IssueWarningQuota, ProhibitSendQuota, ProhibitSendReceiveQuota | Out-GridView
5.) Now the results are in a separate window! Extreme usefull when you’ve have to search for a specific result or results.

25-06-2015 10-11-47    25-06-2015 10-13-47    25-06-2015 10-15-00

25-06-2015 10-16-22    25-06-2015 10-20-51    25-06-2015 10-21-12

How to: Removing Windows 8.1 Modern Apps with PowerShell

When you install a default Windows 8.1 machine, there’re a few modern apps available. In some environments, you want
to remove these modern apps for your users.

With the following steps, you can delete specific apps or all the modern apps.

1.) To get a overview off all the package, use the following command:
Get-AppxPackage | ft Name, PackageFullName -AutoSize
2.) Let’s remove the Finance modern app
Remove-AppxPackage -Package Microsoft.BingFinance_3.0.1.172_x64__8wekyb3d8bbwe -Confirm:$false
3.) Return to the start menu and now you’ll see the Finance app is gone
4.) To remove all the modern apps, use the following command:
Get-AppxPackage | Remove-AppxPackage -Confirm:$false

2015-03-13_14h52_51    2015-03-13_15h24_13    2015-03-13_15h24_54

2015-03-13_15h25_13    2015-03-13_15h26_15    2015-03-13_15h26_25

2015-03-13_15h27_21    2015-03-13_15h27_27

Microsoft Virtual Machine Converter 2.0

Screen-Shot-2014-04-08-at-22.10.53

Microsoft® Virtual Machine Converter (MVMC) is a Microsoft-supported, stand-alone solution for the information technology (IT) pro or solution provider who wants to convert virtual machines and disks from VMware hosts to Hyper-V® hosts and Windows Azure™.

MVMC can be deployed with minimal dependencies. Because MVMC provides native support for Windows PowerShell®, it enables scripting and integration with data center automation workflows such as those authored and run within Microsoft System Center Orchestrator 2012 R2. It can also be invoked through the Windows PowerShell® command-line interface. The solution is simple to download, install, and use. In addition to the Windows PowerShell capability, MVMC provides a wizard-driven GUI to facilitate virtual machine conversion.

New Features in MVMC 2.0
MVMC 2.0 release of MVMC includes the following new features:
◾Converts virtual disks that are attached to a VMware virtual machine to virtual hard disks (VHDs) that can be uploaded to Windows Azure.
◾Provides native Windows PowerShell capability that enables scripting and integration into IT automation workflows.
Note The command-line interface (CLI) in MVMC 1.0 has been replaced by Windows PowerShell in MVMC 2.0.
◾Supports conversion and provisioning of Linux-based guest operating systems from VMware hosts to Hyper-V hosts. ◾Supports conversion of offline virtual machines.
◾Supports the new virtual hard disk format (VHDX) when converting and provisioning in Hyper-V in Windows Server® 2012 R2 and Windows Server 2012.
◾Supports conversion of virtual machines from VMware vSphere 5.5, VMware vSphere 5.1, and VMware vSphere 4.1 hosts Hyper-V virtual machines.
◾Supports Windows Server® 2012 R2, Windows Server® 2012, and Windows® 8 as guest operating systems that you can select for conversion.

Standard MVMC Features  
In addition to the new features previously identified, MVMC provides the following functionality:
◾Converts and deploys virtual machines from VMware hosts to Hyper-V hosts on any of the following operating systems: ◾Windows Server® 2012 R2
◾Windows Server® 2012
◾Windows Server 2008 R2 SP1
◾Converts VMware virtual machines, virtual disks, and configurations for memory, virtual processor, and other virtual computing resources from the source to Hyper-V.
◾Adds virtual network interface cards (NICs) to the converted virtual machine on Hyper-V.
◾Supports conversion of virtual machines from VMware vSphere 5.5, VMware vSphere 5.0, and VMware vSphere 4.1 hosts to Hyper-V.
◾Has a wizard-driven GUI, which simplifies performing virtual machine conversions.
◾Uninstalls VMware Tools before online conversion (online only) to provide a clean way to migrate VMware-based virtual machines to Hyper-V.
Important  MVMC takes a snapshot of the virtual machine that you are converting before you uninstall VMware Tools, and then shuts down the source machine to preserve state during conversion. The virtual machine is restored to its previous state after the source disks that are attached to the virtual machine are successfully copied to the machine where the conversion process is run. At that point, the source machine in VMware can be turned on, if required. Important  MVMC does not uninstall VMware Tools in an offline conversion. Instead, it disables VMware services, drivers, and programs only for Windows Server guest operating systems. For file conversions with Linux guest operating systems, VMware Tools are not disabled or uninstalled. We highly recommend that you manually uninstall VMware Tools when you convert an offline virtual machine.
◾Supports Windows Server and Linux guest operating system conversion. For more details, see the section “Supported Configurations for Virtual Machine Conversion” in this guide.
◾Includes Windows PowerShell capability for offline conversions of VMware-based virtual hard disks (VMDK) to a Hyper-V–based virtual hard disk file format (.vhd file).  Note The offline disk conversion does not include driver fixes.

You can download Microsoft Virtual Machine Converter 2.0 here

How to: Create a VM within a few second in Hyper-V 2012 R2

In some cases I’ve to create multiple VM’s within my Hyper-V environment. You can choose to create and configure each VM manually, but you can also use PowerShell. Now you can see how powerfull PowerShell really is! I’ve created multiple VM’s within a few seconds and ready to rock! I’ve created the following script. The only thing you’ve to do, is changing some variables 🙂

In this example the script will create a new VM named RES-MGN01. The VM will be configured with 2 GB, using Dynamic Memory. The VM is using a differencing disk (VHDK) with a Windows Server 2012 R2 sysprepped parent VHDX, placed on an SSD disk (P: drive) in my server. The virtual switch the VM is connected to, is named NIC – WAN.

$VMName = “RES-MGN01”
$VMMemMaxBytes = 2048MB
$VHDXName = “OS.vhdx”
$VMMemStartup = 512MB
$VMMemMinBytes = 512MB
$VMPath = “E:\”
$VHDParent = “P:\Hyper-V Parents\TMPL-W2012R2DC\Virtual Hard Disks\TMPL-W2012R2DC.vhdx”
$VMSwitchName = “NIC – WAN”

New-VM -Name $VMName -Path $VMpath$VMName -Generation 2 -SwitchName $VMSwitchName

Set-VM -Name $VMName -DynamicMemory -MemoryStartupBytes 512MB -MemoryMinimumBytes $VMMemMinBytes -MemoryMaximumBytes $VMMemMaxBytes

New-VHD -ParentPath $VHDParent -Path $VMPath\$VMName\$VMName\$VHDXName -Differencing

Add-VMHardDiskDrive -VMName $VMName -Path $VMPath\$VMName\$VMName\$VHDXName

Add-VMDvdDrive -VMName $VMName

Start-VM -Name $VMName

2014-01-14_11h48_41    2014-01-14_11h49_20    2014-01-14_11h50_27

2014-01-14_11h51_18    2014-01-14_11h52_12

How to: Create multiple boundaries in ConfigMgr 2012 within a few seconds

When you’re installing and configuring a new ConfigMgr 2012 environment, one of the steps is to configure the right boundaries for your environment. Sometimes there’re only a few boundaries you have to create, but what if there’re several boundaries to configure. Are you gonna click that much….Let’s create some Powershell command to do the job for us.

1.) First of all we are going to import the ConfigMgr 2012 Powershell module. Use the x86 Windows PowerShell, bacause x64 is not supported!!
Import-Module “C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1”
4.) Make a connection to your Primary Site server
Set-Connection P01
3.) Now we are going to create some new boundaries. In this example a whole IP subnet (172.16.10.0 and 172.16.11.0)
New-CMBoundary -Name “Client VLAN1” -Type IPsubnet -Value “172.16.10.0”
New-CMBoundary -Name “Client VLAN2” -Type IPsubnet -Value
“172.16.11.0”
5.) Create a new boundary group. In my example “Main Building”
New-CMBoundaryGroup -Name “Main Building”
6.) The next step is to add the boundaries to the right boundary group
Add-CMBoundaryToGroup -BoundaryName “Client VLAN1” -BoundaryGroupName “Main Building”
Add-CMBoundaryToGroup -BoundaryName “Client VLAN2” -BoundaryGroupName “Main
Building”

Now the job is done. How easy and fast was that…

CMB_01    CMB_02    CMB_03

CMB_04    CMB_05    CMB_06

CMB_07    CMB_08    CMB_09

CMB_10    CMB_11    CMB_12

How to: Enable Jumbo frames on your ISCSI network interface using PowerShell

When building an Windows Server 2012 Hyper-V environment, you want to automate some steps on all the cluster nodes. One of this steps is definitely enabling Jumbo frames on your ISCSI interface(s). You can do this on the properties of you NIC interface, but when you’re installing Hyper-V 2012 Server…YES, there’s no GUI.

The great thing is that there is something called PowerShell ;). You can configure Jumbo frames using PowerShell.

1.) Open PowerShell
2.) Generate an overview of all the Network Interfaces in your Hyper-V host
Get-NetAdapter | ft Name
In my labenvironment there are two ISCSI interfaces (ISCSI01 and ISCSI02)
3.) Show the advanced NIC properties of the ISCSI interfaces
Get-NetAdapterAdvancedProperty -name ISCSI01
Get-NetAdapterAdvancedProperty -name
ISCSI02
As you can see, Jumbo Packet is Disabled
4.) Configure the most common Jumbo Frame setting of 9014 bytes. Note that not all SAN’s supports this value.
Set-NetAdapterAdvancedProperty -Name ISCSI01 -RegistryKeyword “*JumboPacket” -Registryvalue 9014
Set-NetAdapterAdvancedProperty -Name ISCSI02 -RegistryKeyword “*JumboPacket” -Registryvalue 9014
5.) Now Jumbo frames is enabled
Get-NetAdapterAdvancedProperty -name ISCSI01
Get-NetAdapterAdvancedProperty -name
ISCSI02

JF_01    JF_02    JF_03

JF_04    JF_05    JF_06

How to: Create a NIC team within Windows Server 2012

A very nice new feature in Windows Server 2012 is native NIC teaming. This means you can create a team of different NIC’s, without instelling any 3th party drivers or software! Even with different NIC families, for example Intel and Broadcom. Cool!

Within a few clicks, youre NIC team is up and running. Offcourse you can also use PowerShell to manager or create a NIC team. Let’s have a look on some examples from my labenvironment. I’ve created a virtual Windows Server 2012 machine whit a copple of NIC’s in it.

1.) To list all adapter in the machine, you can use the following command
Get-NetAdapter
2.) Rename the adapters
Rename-NetAdapter -Name OLDNAME -NewName NEWNAME
In my example I’m going to create a team of 4 network interfaces (TEAM-INT1,2,3 and 4)
3.) The next step is to create a new team interface
New-NetLbfoTeam -Name LAN-TEAM -TeamMembers TEAM-INT-1, TEAM-INT-2, TEAM-INT-3
As you can see, I’ve only added 3 NIC’s to the team. In the next step, we’re going to add another NIC to the team.
4.) Next we are going to add TEAM-INT-4 to the LAN-TEAM
Add-NetLbfoTeamMebmer -Team LAN-TEAM -InterfaceAlias TEAM-INT-4
5.) Let’s view the team properties
Get-NetLbfoTeam -Name LAN-TEAM
As you can see, all the 4 NIC’s are member of the NIC team
6.) Open the Server Manager and select “Local Server”
7.) Select “NIC Teaming” Here you can edit the properties of your NIC team and see the status of each interface (speed, status, etc.)
8.) When we disable one interface, you see the new status directly

So in this exmple, you have seen how easy it is to build a new NIC team with different NIC’s. No special drivers, no tooling, no 3th party software…just Windows Server 2012!! #cool!

NIC_Team_01    NIC_Team_02    NIC_Team_03

NIC_Team_04    NIC_Team_05    NIC_Team_06

NIC_Team_07    NIC_Team_08    NIC_Team_09

NIC_Team_10    NIC_Team_11

How to: Create a Shutdown/Restart/Logoff Windows 8 Tile for the Start menu

In the Microsoft Script Center you can download a powershell script to create a Shutdown/Restart/Logoff tile for the Start menu in Windows 8. This is so cool!! 🙂 It’s also very easy to use when you connect to an Windows 8 machine through the Remote Desktop Protocol, you’re now able to shutdown this host remotely!

http://gallery.technet.microsoft.com/scriptcenter/Create-a-ShutdownRestartLog-37c8111d

1.) Fist edit the Execution Policy on your desktop
Set-ExecutionPolicy unrestricted
2.) Type the command Import-Module <path to script>
Import-Module
C:\Script\CreateWindowsTile.psm1
3.) Type the command New-OSCWindowsTile
4.) Navigate to start and there are the three new tiles!