header image

Archive for April, 2009

How many bytes?

Posted by: | April 30, 2009 | No Comment |

I was playing around with PowerShell and started thinking about the kb, mb etc values and I realised I didn’t know what they really looked like.  1kb is 1024 but it gets very hazy after that. So how could I see the values stacked up 1kb,1mb,1gb,1tb,1pb | foreach{"$_".PadLeft(16)} works.  We feed in the list of […]

under: PowerShell original, PowerShellV2

Creating a process

Posted by: | April 28, 2009 | No Comment |

I’ve looked at creating a process before – using [WMIClass].   With CTP3 we have a few more options   Start-Process -Filepath notepad.exe   Invoke-WMIMethod -Class Win32_process -Name Create -ArgumentList notepad.exe   Set-WMIinstance -Class Win32_process -Arguments @{Path=c:\windows\system32\notepad.exe}   The first two just happen.  The third option will throw an exception because it can’t find the […]

under: PowerShell and WMI

PowerShell verbs

Posted by: | April 27, 2009 | No Comment |

If you haven’t seen the post on PowerShell standard verbs from the PowerShell team it is worth reading – http://blogs.msdn.com/powershell/archive/2009/04/22/soliciting-new-verbs.aspx   If you have an idea for a new verb – make sure you make it known

under: PowerShellV2

One of the big pieces of functionality in PowerShell v2 is the ability to directly administer remote machines.  A number of cmdlets get a computername parameter for working directly. The main push for remoting is through the *-PSsession cmdlets Enter-PSSessionExit-PSSessionExport-PSSessionGet-PSSessionImport-PSSessionNew-PSSessionRemove-PSSession New-, Get and Remove- I have blogged about before.  The interesting ones are the Enter/Exit […]

under: PowerShellV2

Too ambitious?

Posted by: | April 25, 2009 | No Comment |

Been looking at Exchange 2010.  It installed OK on Windows 2008 R2 Beta and seemed to run OK.  I have come across a few issues: Exchange Management Console doesn’t start properly and doesn’t run properly The new Remote PowerShell functionality doesn’t work (against Windows 7) I think this is due to trying to work two […]

under: PowerShell original

AD attributes

Posted by: | April 23, 2009 | No Comment |

I had a question come through as a private message regarding how to extract a particular attribute for user objects. The script wasn’t working because the label name in AD Users and Computers didn’t match the attribute name. This is a fairly common scenario as there are quite a few attributes like this for instance […]

under: PowerShell and Active Directory

Sorting

Posted by: | April 22, 2009 | No Comment |

Sorting is a fairly common activity in PowerShell.  One scenario I don’t see very often is a requirement to sort in two different directions.  I have a list of users and their last logon dates – I want to sort users into alphabetical order (ascending) and lat logon into descending order. 001 Import-Csv logons.txt | sort @{Expression="Name";Descending=$false},@{Expression="LastLogon";Descending=$true} We have […]

under: PowerShell original

Back in February – http://richardsiddaway.spaces.live.com/blog/cns!43CFA46A74CF3E96!2099.entry – I showed a module I had created to generate a new password.  Its time to return to that module.  I am going to expand it to work with local user accounts. Then I’ll add AD accounts. I have a script that I wrote a while back to work with […]

under: PowerShellV2

Forest and domain modes

Posted by: | April 20, 2009 | No Comment |

We can find the forest and domain modes using the following commands Get-ADDomain -Identity grayson | select DomainMode Get-ADForest grayson | select forestmode The modes can be set from the GUI as normal or Set-ADDomainMode -Identity grayson -DomainMode Windows2008R2DomainSet-ADForestMode -Identity grayson -ForestMode Windows2008R2Forest Not that you will be using these cmdlets very often   Technorati […]

under: PowerShell and Active Directory

Two PowerShells

Posted by: | April 20, 2009 | No Comment |

Windows Server 2008 R2 is 64 bit only so we we get two instances of PowerShell and ISE.  One (64bit version) is just labelled Windows PowerShell V2 and Windows PowerShell V2 ISE.  The 32bit version has (x86) appended to the name. One point to watch for – the 64 and 32bit versions have different execution […]

under: PowerShellV2

Older Posts »

Categories