Categories

16288

Toggling between LAN and Wireless

One of the questions in the recent Scripting Games involved toggling between a wireless and LAN connection. Only one was to be up at any one time.

This can be solved using WMI but becomes hugely simpler in Windows 8/2012 as we get a bunch of cmdlets for working with network adapters.

Using WMI

Get-WmiObject -Class Win32_NetworkAdapter | Measure-Object

I get 15 objects returned on my system – but I’m only interested in 2 of them!

Using the new functionality

PS> Get-NetAdapter | ft -a Name, ifIndex, Status

Name             ifIndex Status
----             ------- ------
Virtual Wireless      21 Disabled
Virtual LAN           12 Up

This leads to a simple piece of code

Get-NetAdapter |
foreach {
  $nic = $_
  switch ($_.Status){
   "Up"        {Disable-NetAdapter -InputObject $nic -Confirm:$false}
   "Disabled"  {Enable-NetAdapter -InputObject $nic -Confirm:$false}

  }
}

Get the adapter, test its status and toggle to the other.

These cmdlets are in the NetAdapter module which is created using the cmdlets over objects techniques to utilise WMI classes in a much friendlier way. Remoting capabilities are supplied by CIMsessions

Using Windows 2012 Active Directory module in a Windows 2008 R2 domain

A question came up on Tuesdays UK PowerShell Group session about using the Windows 2012 Active Directory module. The recording links are here

http://msmvps.com/blogs/richardsiddaway/archive/2012/05/30/may-2012-powershell-group-recording-and-slides.aspx

The question asked if the new Site, Subnet and Site link cmdlets would work in a legacy environment.

This morning I installed a Windows Server 2012 Release Candidate member server into my Windows 2008 R2 domain. I then installed the RSAT feature on the Windows 2012 server – this includes the Active Directory module.

The site, subnet and site link cmdlets appear to work with NO changes required to the Windows 2008 R2 domain controller. I was able to view and create sites, subnets and site links.

I haven’t tested any other scenario.

Scheduled tasks on clusters

This post shows how to use PowerShell in Windows Server 2012 to configure scheduled tasks that apply across the whole cluster not just a single node

http://blogs.msdn.com/b/clustering/archive/2012/05/31/10312527.aspx

Well worth a read

May 2012 Powershell group recording and slides

 

The recording, slides and demo scripts from last nights session  - Powershell in Windows Server 8 part 2  - is available from

https://skydrive.live.com/?cid=43cfa46a74cf3e96#cid=43CFA46A74CF3E96&id=43CFA46A74CF3E96%212966

The full set of historical recordings can be found here:

https://skydrive.live.com/#cid=43CFA46A74CF3E96&id=43CFA46A74CF3E96%212469

2011 09 PowerShell remoting and end point customisation
2011 11 Whats new in PowerCLI 5
2011 12 Intro to WMI
2011 12 WSMAN_WMI_and_CIM
2012 January PowerShell v3 CTP 2 overview
2012 February PowerShell and SQL Server
2012 March CIM cmdlets
2012 April Powershell in Windows Server 8
2012 May Powershell in Windows Server 8 part 2 

Older folders just have the slides

May UG meeting reminder

Quick reminder that the UK PowerShell group session on PowerShell in Windows 2012 is on Tuesday 29 May. Details from

http://msmvps.com/blogs/richardsiddaway/archive/2012/05/08/uk-powershell-group-may-2012.aspx

UK PowerShell Group–April 2012 slides and recording

The slides, demo script and recording are available from

https://skydrive.live.com/?cid=43cfa46a74cf3e96#cid=43CFA46A74CF3E96&id=43CFA46A74CF3E96%212957

Thank you again to everyone who attended the Live Meeting this evening

Reminder–UK User group 24 April

Quick reminder that 24 April sees the first of 2 sessions on new PowerShell functionality in Windows 2012 – Windows Server 8

Details from

http://msmvps.com/blogs/richardsiddaway/archive/2012/04/13/uk-powershell-group-24-april-2012.aspx

UK PowerShell Group–24 April 2012

This months meeting is the first of two looking at the new PowerShell functionality in Windows Server 8. Yes, there is so much it will take two sessions!


When: Tuesday, Apr 24, 2012 7:30 PM (BST)


Where: Virtual

*~*~*~*~*~*~*~*~*~*


This is the first of two meetings looking at the new PowerShell functionality available in Windows Server 8

Notes



Richard Siddaway has invited you to attend an online meeting using Live Meeting.
Join the meeting.
Audio Information
Computer Audio
To use computer audio, you need speakers and microphone, or a headset.
First Time Users:
To save time before the meeting, check your system to make sure it is ready to use Microsoft Office Live Meeting.
Troubleshooting
Unable to join the meeting? Follow these steps:

  1. Copy this address and paste it into your web browser:
    https://www.livemeeting.com/cc/usergroups/join
  2. Copy and paste the required information:
    Meeting ID: S5NC59
    Entry Code: c^]"2]44W
    Location: https://www.livemeeting.com/cc/usergroups

If you still cannot enter the meeting, contact support

Notice
Microsoft Office Live Meeting can be used to record meetings. By participating in this meeting, you agree that your communications may be monitored or recorded at any time during the meeting.

Up coming User group sessions

The sessions for the next few months are:

  • 27 March – PowerShell v3 CIM cmdlets and “cmlets over objects”
  • April – Managing Windows Server 8 with PowerShell
  • May – Managing Windows Server 8 with PowerShell

No thats not a mistake – there is so much new PowerShell functionality in Windows server 8 that two sessions will just scratch the surface.  I’m delivering the April session and PowerShell MVP Jonathan Medd is delivering the May session.

Details on March’s sessions from

http://msmvps.com/blogs/richardsiddaway/archive/2012/03/06/uk-powershell-group-march-2012.aspx

As always the session will be recorded and made available afterwards.

Creating a new AD forest

One big change with Windows Server 8 is that dcpromo is no more – its gone, gone gone.

Instead the promotion wizard is started from Server Manager. Install the AD Domain Services role and you will see a notification at the top right of the Server Manager console with a complete Active Directory configuration option.  Click that and the wizard starts. If you’ve used dcpromo on earlier versions of Windows there won’t be any surprises.

Best of all you get the PowerShell commands to do the job

Import-Module ADDSDeployment
Install-ADDSForest `
-CreateDNSDelegation:$false `
-DatabasePath "C:\Windows\NTDS" `
-DomainMode "Win8" `
-DomainName "Beta8.test" `
-DomainNetBIOSName "BETA8" `
-ForestMode "Win8" `
-InstallDNS:$true `
-LogPath "C:\Windows\NTDS" `
-RebootOnCompletion:$true `
-SYSVOLPath "C:\Windows\SYSVOL" `
-Force:$true

already to be re-used.  The AD Administrative Centre also produces the PowerShell it uses under the hood but thats a story for another day.

The ADDSDeployment module has a number of cmdlets

PS> Get-Command -Module ADDSDeployment

Capability      Name
----------      ----
Cmdlet          Add-ADDSReadOnlyDomainControllerAccount
Cmdlet          Install-ADDSDomain
Cmdlet          Install-ADDSDomainController
Cmdlet          Install-ADDSForest
Cmdlet          Test-ADDSDomainControllerInstallation
Cmdlet          Test-ADDSDomainControllerUninstallation
Cmdlet          Test-ADDSDomainInstallation
Cmdlet          Test-ADDSForestInstallation
Cmdlet          Test-ADDSReadOnlyDomainControllerAccountCreation
Cmdlet          Uninstall-ADDSDomainController

 

I’ll be trying out the Install-ADDSDomainController soon