PowerShell for Windows Admins


May 11, 2014  4:43 AM

PowerShell Summit Europe 2014 – Call for Topics

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

The PowerShell Summit is the number one place where PowerShell enthusiasts gather and learn from each other in fast-paced, knowledge packed presentations. Experts from all over the world including MVP’s, Guru’s, and PowerShell team members, join together for a few days to discuss and learn how to maximize using PowerShell in the workplace.

And now the PowerShell Summit is coming to Europe. PowerShell Summit Europe 2014 will be held September 29, 30, and October 1 at the Hotel Park in Amsterdam, Holland. http://powershell.org/wp/community-events/summit/powershell-summit-europe/ If you want to share your PowerShell expertise, then this is your official call to submit presentations for selection!

Topic Areas – What we are looking for W

e are looking for 45-minute presentations covering a wide aspect of PowerShell expertise. We have three main topic areas that may assist you in building an abstract. • PowerShell Internals – A deep look into the inside workings of PowerShell and practical solutions that are built from them. These presentations are more focused on the PowerShell development community that is building extensions and solutions relating to PowerShell. • PowerShell in Production – These presentations are focused on domain specific PowerShell solutions for IT Pro’s such as managing Exchange, System Center, IIS, SharePoint, VMware and more. • PowerShell Features Deep Dive – These presentations are a deep look into configuring and working with PowerShell features and capabilities such as PowerShell Remoting, PowerShell Web Access, Reporting and more.

We are open to presentations across the entire ecosystem that has been built around PowerShell; so don’t hesitate to send an abstract for your particular area of expertise. And don’t think, “oh, I can’t do a presentation!” We aren’t looking for Toastmasters winners – we’re looking for folks to be a part of the community! Take the leap and present! Each session is only 35 minutes, with 10 minutes for Q&A!

Presentation submissions – What you should send to us

Presentations will be 45-minutes in length (planning for 30-40 minutes of material and 5-15 minutes of Q&A) and the submission should include the following: • Presentation Title • Presentation abstract – a description of the presentation and the topics covered. 100 words or less and suitable for marketing. • 50 word biography

You can submit multiple presentations in the same topic area or for different ones.

What you get if you present

The European Summit is working to a very tight budget as this is the first time we are running it. Compensation for speakers will be free admission (not free Association for Windows PowerShell Professionals membership, http://powershell.org/wp/association-for-windows-powershell-professionals, just free admission, which includes food). We will not reimburse hotel, expenses, or travel. It’s important that speakers not register for the conference, because we will not be refunding you if you do that. The financial situation may change to a certain degree if the event sells out but we can’t cover all of your expenses as a speaker and we can’t make any guarantees at this stage.

We also ask that you help publicize the event.

Presentation submission deadline – When you should send it by

Start sending your presentation submissions immediately! The selection committee will start selecting presentations as soon as they arrive so you don’t want to miss out. The last day we will accept presentation submissions will be May 23, 2014. Send your proposals to cft2014eu@powershell.org. Please either put multiple proposals in a Word doc, or send just one proposal in the body of an email, so that we can track these more easily.

When you will know you’ve been selected

The selection committee will start reviewing submissions immediately and begin the selection process. You will be informed if one or more of your presentations have been selected and sent a contract on or before June 14, 2014. You will need to return the signed contract by June 21, 2014.

The final agenda will be announced early July and posted on PowerShell.Org. We look forward to your submissions and your help in making PowerShell Summit Europe 2014 your most valuable IT/Dev conference of the year!

April 30, 2014  8:39 AM

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

We are trying to raise the money to purchase equipment to record the sessions at future PowerShell Summit’s

http://powershell.org/wp/2014/04/28/help-us-record-the-powershell-summit-sessions/

If you can help us – please do.

There have been some amazing sessions this year – when you watch people’s jaws drop you know the content is great.

If we can record the sessions attendees can see the sessions they missed and non-attendees can see what they are missing

Thank you


April 29, 2014  7:39 AM

Update on Office error

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Back in this post http://richardspowershellblog.wordpress.com/2012/10/15/powershell-3-and-word/

I showed that this code

$word = New-Object -ComObject “Word.application”

$word.visible = $true

$doc = $word.Documents.Add()

$doc.Activate()

$word.Selection.Font.Name = “Cambria”

$word.Selection.Font.Size = “20″

$word.Selection.TypeText(“PowerShell”)

$word.Selection.TypeParagraph()

$word.Selection.Font.Name = “Calibri”

$word.Selection.Font.Size = “12″

$word.Selection.TypeText(“The best scripting language in the world!”)

$word.Selection.TypeParagraph()

$file = “c:\test1.doc”

$doc.SaveAs([REF]$file)

$Word.Quit()

 

Wouldn’t work because of an error in the way [REF] was treated. I had a comment left on the post saying it worked on PowerShell v4.

I’ve tested on PowerShell v4 on Windows 8.1 with Office 2013. It works. I can’t vouch for other combinations but it looks the problem has been resolved.

If you have the opportunity please try it and let me know if it doesn’t work for your particular combination of PowerShell v4, Windows and Office


April 29, 2014  7:20 AM

PowerShell Summit NA 2014–day 1

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Day one of the Summit has been and gone and it has lived up to expectations. With more attendees and more sessions than last year this is the place to be if you want your PowerShell questions answered.

One of the highlights of day 1 was Steve Muraski’s sessions on DSC. He has recorded them and will be making them available – I’ll post the link when available.


April 25, 2014  3:49 PM

To the Summit

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Off to the PowerShell Summit tomorrow morning – 3 days of wall to wall PowerShell with some of the most knowledgeable people in the world.  Its going to be fun.

More details of the European Summit will be coming soon – remember its 20 September – 1 October in Amsterdam


April 21, 2014  10:40 AM

Working with Server Core–Domain join

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Windows Server can be installed in two ways – full fat GUI or Server Core.  The latter is Windows without Windows.  The GUI components are stripped off and you’re just left with the core components.  This results in a smaller server – I’ve got 2 machines running in my Hyper-V test environment. Both are set to use dynamic memory with 512MB startup RAM. The full GUI machine needs 1126MB while the Server Core version needs 566MB.

With Server Core all you get is a prompt for administration – unfortunately its cmd.exe but typing powershell starts PowerShell – including running a profile.

Without a GUI you need to use the command line to do everything – I’ll be doing my demos at the PowerShell Summit from Server Core machines so some things will have to wait until after then – and I’m going to do a series on posts on administering Server Core machines.

I’ve already shown you  how to test if your machine is activated.  This how you join it to the domain.

Make sure that the IP and DNS server addresses have been set so the machine can find a domain controller.

$cred = Get-Credential

Add-Computer -Credential $cred -DomainName sphinx -Restart

Create a credential for the account that can join the machine to the domain.  use Add-Computer and supply the credential and domain name. The –ReStart parameter forces a restart post domain join.

if you want to see the results of calling Add-Computer then drop the restart switch and use Restart-Computer whenever you want the restart to happen


April 19, 2014  7:52 AM

Subnets and prefixes

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Sounds a bit like an old time role playing game but is actually a useful piece of knowledge.

You can define a subnet mask in 2 ways. Either use the full mask e.g. 255.255.248.0 or define the number of bits in the mask e.gg 21 which is known as the prefixlength in the PowerShell networking cmdlets.

But can you relate a full subnet mask to the number of bits. Some are obvious but the others I need to work out.

Time for a quick PowerShell function:

function show-subnetmask{

foreach ($prefixlength in 8..30) {

switch ($prefixlength){

{$_ -gt 24}

{

$bin = (’1′ * ($prefixlength – 24)).PadRight(8, ’0′)

$o4 = [convert]::ToInt32($bin.Trim(),2)

$mask = “255.255.255.$o4″

break

}

{$_ -eq 24}

{

$mask = ’255.255.255.0′

break

}

{$_ -gt 16 -and $_ -lt 24}

{

$bin = (’1′ * ($prefixlength – 16)).PadRight(8, ’0′)

$o3 = [convert]::ToInt32($bin.Trim(),2)

$mask = “255.255.$o3.0″

break

}

{$_ -eq 16}

{

$mask = ’255.255.0.0′

break

}

{$_ -gt 8 -and $_ -lt 16}

{

$bin = (’1′ * ($prefixlength – 8)).PadRight(8, ’0′)

$o2 = [convert]::ToInt32($bin.Trim(),2)

$mask = “255.$o2.0.0″

break

}

{$_ -eq 8}

{

$mask = ’255.0.0.0′

break

}

default

{

$mask = ’0.0.0.0′

}

}

New-Object -TypeName psobject -Property @{

PrefixLength = $prefixlength

Subnetmask = $mask

}

}

}

 

Most people will be using subnets between 8 and 30 bits in length so start with that range and for each value work through the switch statement. If the value is 8,16 or 24 the subnet mask can be set directly. Otherwise it needs to be calculated. The calculations are the same – the difference is which octet of the subnet mask is affected.

For instance if the prefix length is between 16 and 24 (exclusive)

$bin = (’1′ * ($prefixlength – 16)).PadRight(8, ’0′)

$o3 = [convert]::ToInt32($bin.Trim(),2)

$mask = “255.255.$o3.0″

break

Convert the number to a binary representation – the amount you need to subtract depends on the octet with which you are working

Convert the binary to an integer and insert into the subnet mask string.

An object is output that has the subnet mask and prefix length as properties.

Put the function in a module on your module path and you’ll be able to use it as a quick lookup when you need to convert subnet masks to prefix lengths or vice versa

 


April 16, 2014  11:30 AM

WMI against remote machines

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

WMI is a great tool for managing your Windows machines – I’d argue that PowerShell wouldn’t be as powerful as it is without WMI. If you question that remember that 60% of the additional cmdlets in Windows Server 2012 & 2012 R2 are CDXML based i.e. publish a WMI class as a PowerShell module.

PowerShell 2.0 introduced a suite of WMI cmdlets:

Get-WmiObject

Invoke-WmiMethod

Register-WmiEvent

Remove-WmiObject

Set-WmiInstance

PowerShell 3.0 introduced the CIM cmdlets:

Get-CimAssociatedInstance

Get-CimClass

Get-CimInstance

Get-CimSession

Invoke-CimMethod

New-CimInstance

New-CimSession

New-CimSessionOption

Register-CimIndicationEvent

Remove-CimInstance

Remove-CimSession

Set-CimInstance

 

So which should you use?

There are a number of differences.

The WMI cmdlets return live objects and the CIM cmdlets return inert objects. This isn’t too much of an issue if you use Invoke-CimMethod. I’d also recommend using Invoke-WMImethod over creating an object and calling the method on that.

The real difference is in the protocol used to access remote machines. The WMI cmdlets use DCOM and the CIM cmdlets default to WSMAN. At this point you may be thinking that you can just use the CIM cmdlets but the remote machine must be running WSMAN 3.0 which comes with PowerShell 3.0 or 4.0.. The CIM cmdlets can’t connect to WSMAN 2.0 which is the PowerShell 2.0 version.

At that point you have to use a CIM session that drops back to DCOM or run Get-WMIobject through a PowerShell remoting session.

Overall the CIM cmdlets win – especially when you consider Get-CimClass and Get-CimAssociatedInstance

 

 


April 15, 2014  10:06 AM

PowerShell versions

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

I’ve been using the CIM cmdlets for a number of posts recently and had a comment that a reader got a message that Get-CimInstance didn’t exist on their Windows 7 machine.

Windows 7 ships with PowerShell 2.0; Windows 8 with PowerShell 3.0 and Windows 8.1 with PowerShell 4.0.

You need PowerShell 3.0 or 4.0 to have the CIM cmdlets.

You can install PowerShell 3.0 or 4.0 on Windows 7. You need to go to the Microsoft download site, download and install the appropriate version of Windows Management Framework (WMF 3 contains PowerShell 3.0 and WMF 4 contains PowerShell 4.0).

You can tell which version of PowerShell you are running by looking in the $psversiontable automatic variable:

 

£> $psversiontable

Name Value

—- —–

PSVersion 4.0

WSManStackVersion 3.0

SerializationVersion 1.1.0.1

CLRVersion 4.0.30319.34014

BuildVersion 6.3.9600.16394

PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}

PSRemotingProtocolVersion 2.2

 


April 14, 2014  2:43 PM

Status of Office software

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

You can also use the SoftwareLicensingProduct CIM class to test the status of your Office products.

Get-CimInstance -ClassName SoftwareLicensingProduct -Filter “Name LIKE ‘Office%’” |

where PartialProductKey |

select Name, ApplicationId, LicenseStatus

You need to be careful with Office as you might find a lot more options than you expected. On my machine I found this:

Get-CimInstance -ClassName SoftwareLicensingProduct -Filter “Name LIKE ‘Office%’” | select Name -Unique | sort name

Office 15, OfficeO365ProPlusR_Grace edition

Office 15, OfficeO365ProPlusR_Retail edition

Office 15, OfficeO365ProPlusR_Subscription1 edition

Office 15, OfficeO365ProPlusR_Subscription2 edition

Office 15, OfficeO365ProPlusR_Subscription3 edition

Office 15, OfficeO365ProPlusR_Subscription4 edition

Office 15, OfficeO365ProPlusR_Subscription5 edition

Office 15, OfficeO365ProPlusR_SubTrial1 edition

Office 15, OfficeO365ProPlusR_SubTrial2 edition

Office 15, OfficeO365ProPlusR_SubTrial3 edition

Office 15, OfficeO365ProPlusR_SubTrial4 edition

Office 15, OfficeO365ProPlusR_SubTrial5 edition

Office 15, OfficeO365SmallBusPremR_Grace edition

Office 15, OfficeO365SmallBusPremR_Retail edition

Office 15, OfficeO365SmallBusPremR_Subscription1 edition

Office 15, OfficeO365SmallBusPremR_Subscription2 edition

Office 15, OfficeO365SmallBusPremR_Subscription3 edition

Office 15, OfficeO365SmallBusPremR_Subscription4 edition

Office 15, OfficeO365SmallBusPremR_Subscription5 edition

Office 15, OfficeO365SmallBusPremR_SubTrial1 edition

Office 15, OfficeO365SmallBusPremR_SubTrial2 edition

Office 15, OfficeO365SmallBusPremR_SubTrial3 edition

Office 15, OfficeO365SmallBusPremR_SubTrial4 edition

Office 15, OfficeO365SmallBusPremR_SubTrial5 edition

Office 15, OfficeProjectProCO365R_Subscription edition

Office 15, OfficeProjectProCO365R_SubTest edition

Office 15, OfficeProjectProCO365R_SubTrial edition

Office 15, OfficeProjectProDemoR_BypassTrial180 edition

Office 15, OfficeProjectProMSDNR_Retail edition

Office 15, OfficeProjectProO365R_Subscription edition

Office 15, OfficeProjectProO365R_SubTest edition

Office 15, OfficeProjectProO365R_SubTrial edition

Office 15, OfficeProjectProR_Grace edition

Office 15, OfficeProjectProR_OEM_Perp edition

Office 15, OfficeProjectProR_Retail edition

Office 15, OfficeProjectProR_Trial edition

Office 15, OfficeProPlusDemoR_BypassTrial180 edition

Office 15, OfficeProPlusMSDNR_Retail edition

Office 15, OfficeProPlusR_Grace edition

Office 15, OfficeProPlusR_OEM_Perp edition

Office 15, OfficeProPlusR_Retail edition

Office 15, OfficeProPlusR_Trial edition

Office 15, OfficeVisioProCO365R_Subscription edition

Office 15, OfficeVisioProCO365R_SubTest edition

Office 15, OfficeVisioProCO365R_SubTrial edition

Office 15, OfficeVisioProDemoR_BypassTrial180 edition

Office 15, OfficeVisioProMSDNR_Retail edition

Office 15, OfficeVisioProO365R_Subscription edition

Office 15, OfficeVisioProO365R_SubTest edition

Office 15, OfficeVisioProO365R_SubTrial edition

Office 15, OfficeVisioProR_Grace edition

Office 15, OfficeVisioProR_OEM_Perp edition

Office 15, OfficeVisioProR_Retail edition

Office 15, OfficeVisioProR_Trial edition

 

which was a lot more than I expected.

It is possible to use WMI to set the product key – use the SoftwareLicensingService class

 


Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: