Archive

Posts Tagged ‘Windows 7’

Joining a Windows 7 Client to a Domain through PowerShell

June 5th, 2009 Niklas Goude 2 comments

Time to join a Windows 7 client to a domain. Now that the Test Domain is up and running ( Check Previous Posts ), we can start joining clients to the domain.

Since it’s a freshly installed Windows 7 client, we dont have to bother about userprofiles and so on.. we’ll save that for later :)

Joining the domain is done through WMI. Just create a new Object containing the Win32_ComputerSystem WMI object and call the JoinDOmainOrWorkGroup() method.


function JoinDomain ([string]$Domain, [string]$User, [string]$Password ) {

	$DomainUser = $Domain + "\" + $User
	$OU = $null

	$ComputerSystem = gwmi Win32_ComputerSystem

	$ComputerSystem.JoinDomainOrWorkGroup(
		$Domain,
		$Password,
		$DomainUser,
		$OU,
		3
	)
}

Here’s an example on running the function.


PS > JoinDomain PowerShell.nu migaccount Password1

And voila! the client shuts down and on Startup, It’ll have joined the new domain.

Rating 3.00 out of 5
[?]
Categories: Projects, Windows 7 Tags: ,

Write-StickyNote

June 5th, 2009 Niklas Goude No comments

Here’s a fun script that uses the new “Sticky Notes” in WIndows 7.

The script is based on a simple function that uses the SendKeys() method through the Wscript.Shell COM object. This is a nice example on how you can handle COM objects through PowerShell.

I’ve also included an if statement that checks if StickyNotes is active. If that’s the case, the text will be started in a new StickyNotes.. note..

Anyway, here’s the function.


function Write-StickyNote ([string]$Text) {

	if (gps | Where { $_.ProcessName -match "stikynot" }) {

		$StickyNote = $True
	}

	$Wscript = New-Object -Com Wscript.Shell
	[void]$Wscript.Run("stikynot.exe")
	start-sleep 1

	if ($StickyNote -eq $True) {

		$Wscript.SendKeys("^n")
	}

	$Wscript.SendKeys($Text)
}

And here’s an example on running the function.


PS > .\Write-StickyNote.ps1 "Hello from PowerShell.nu"

stickynotes01

Click here to download the Script

Rating 3.00 out of 5
[?]
Categories: COM Object, Windows 7 Tags:

Migrate From Windows Server 2003 to Windows Server 2008 R2 and Windows 7 Using PowerShell

April 11th, 2009 Niklas Goude No comments

Windows 7 and Windows Server 2008 R2 are just around the Corner. Beta Versions are very promising and, as it seems, the best OS that Microsoft has ever done! This is something that’s not easy to accomplish in the Beta stage of an OS, but Microsoft has pulled it off! The comparisons that I’ve made with previous Operating Systems are entirely based on self observations.

I’m hoping that alot of people share my enthusiasm regarding the Windows 7 technologies and I would like to share my Beta tests with the Microsoft Community. I’m aware that a few commands and techniques may vary from the final Release so the following posts might not be accurate when the final build of Windows 7 / 2008 R2 are released. I will try to keep these posts up to date and follow Microsfts development of Windows 7 and Windows Server 2008 R2.

Scenraio

You have a Windows 2003 Active-Directory Environment that you want to Updgrade / migrate to a Windows 2008 R2 environment. Microsoft have a great tool called ADMT (Active Directory Migration Tool) which allows you to perform the appropriate steps when migration from Windows 2003 to Windows 2008. But since this is a PowerShell Blog, I’m going to show examples on doing all these steps through PowerShell. I’m planning on showing the following steps:

Windows 2003

Windows 2008 R2

  • Gathering information from a 2003 Active Directory Domain through PowerShell
  • Migarting OU Structure to a Active-Directory 2008 R2 Server Through PowerShell
  • Migarting Users to a Active-Directory 2008 R2 Server Through PowerShell
  • Migarting Computers to a Active-Directory 2008 R2 Server Through PowerShell
  • Migarting Groups to a Active-Directory 2008 R2 Server Through PowerShell
  • Migarting Group Membership to a Active-Directory 2008 R2 Server Through PowerShell
  • Migrating HomeFolders to a Active-Directory 2008 R2 Server Through PowerShell
  • Migrating a Windows 7 Client to a Active-Directory 2008 R2 Server Through PowerShell
  • Note that all steps are built from a test environment and may require slight adjustments to fit your environmnent.

    Rating 3.00 out of 5
    [?]