30 May 2010 @ 12:51 

A while back I posted a script that would take whatever input it got, into a sortable HTML table in a file.

Last night my family was here, and they wanted to see the Eurovision song contest thing, so I had some time to rewrite the script into a PowerShell V2 Advanced function, that supports pipeline input.

There are some examples in the code on how to use the function

I do not know what has happened to code highlighter, but it has suddenly decided to mess up the code, so it is not working on the site, so here is a link to the file.

Out-HTMLTable

Example of output:

Out-HTMLTable example

download | new post

Posted By: Xenophane
Last Edit: 11 Jun 2010 @ 18:54

EmailPermalinkComments (4)
Tags
Tags: ,
Categories: Tech Stuff
 11 May 2010 @ 22:39 

Here is my presentation from the 2010 Minasi conference.

Presentation

Posted By: Xenophane
Last Edit: 11 May 2010 @ 22:39

EmailPermalinkComments (1)
Tags
Categories: Tech Stuff
 11 May 2010 @ 22:14 

Example #1

#Sessions

#Single Session
$Session = New-PSSession -ComputerName "computername"

#Multiple Sessions

$Session = New-PSSession -ComputerName "comp1","comp2".....

#Remove all Sessions

Remove-PSSession *

#Remove Named Session

Remove-PSSession $Session

#Using $session
Invoke-Command {ipconfig} -Session $Session

Enter-PSSession -Session $session

Example #2

$session = New-PSSession -ComputerName "compname"

Invoke-Command {Import-Module ActiveDirectory} -Session $session

Import-PSSession -Session $session -Module ActiveDirectory -Prefix "ctn"

notepad (Get-Module).path

Get-Command *ctn*
Posted By: Xenophane
Last Edit: 11 May 2010 @ 22:28

EmailPermalinkComments (1)
Tags
Tags:
Categories: Tech Stuff
 11 May 2010 @ 21:40 

I got back from Virgina Beach this past Saturday, after attending a very good conference, where I learned a lot of new an exciting stuff… And of course it was very good to meet up with the “gang” again.

This year I did a presentation on Powershell (wow 1 hour and 20 min goes past fast, when you are having fun)
As the presenter rookie I am, I was not able to time my presentation, so when time was up, even went 10 min over time, I still missed about a third of the presentation. So to make up for that, I will post all the scripts and the prensentation in its entirety, so hope you will find it usefull.

Posted By: Xenophane
Last Edit: 11 May 2010 @ 21:40

EmailPermalinkComments (0)
Tags
Tags: , ,
Categories: Tech Stuff
 24 Jan 2010 @ 23:38 

Seems as if Quest has been doing some really cool things with Powershell,  from what I can read, they have “rolled” it up as a webservice, meaning that you can now run your Powershell scripts over HTTPS from either you local machine, your phone,  anything that supports a newer web browser.

From what I can gather from the manual, you install it on a server running IIS, you set up the site, security etc. Then you can connect to the site from a webbrowser, and you will get a PowerShell commandline in your browser.  Combined with Powershell v.2′s remoting features this has the potential of becoming an awesome tool. One of the nice features is that you can save “favourites” in your web sessions,  here favourites should be seen as snippets of Powershell code, that you can just click on the run.

So imagine, you have a Powershell script that runs and checks if a particular service is running, if not it does “Something”. You  are sitting by the pool drinking a nice cold beer, when you get a call that there is trouble in the office. You pick up you android phone, open up a browser connects to www.whereIWork.com/MyPowerShell, login.. click your Powershell favourite/snippet, and your are done..

If you figure out that did not solve the problem, you just do

Enter-PsSession -Computername <Problematic Servername>, you are now running a Powershell session on the remote server, where you can look around the system, and try to fix the problem, as if you were sitting in front the server, with a Powershell console open.

Can’t wait to I can find some time to get it tested, even thoug it still is in Beta.

Posted By: Xenophane
Last Edit: 24 Jan 2010 @ 23:38

EmailPermalinkComments (0)
Tags
Tags: ,
Categories: Tech Stuff
 30 Nov 2009 @ 21:30 

Joel Bennet made a good point about it can be difficult to find Powershell V2 on the MS site. I am not going to rewrite Joels post, so I will just “quote” it.

For some reason, people are having trouble finding links to the release version of Windows PowerShell 2.0 … I suspect it’s because while it was in CTP, a lot of us bloggers wrote about it and linked to the various CTP downloads … but there aren’t nearly as many posts announcing the release of Windows PowerShell 2.0 as you would expect.

Of course, most of the fault is Microsoft’s, because they buried PowerShell 2 in a knowledge base article with a title that exceeds nondescript, even for Microsoft: Description of the Windows Management Framework on Windows XP, Windows Server 2003, Windows Vista, and Windows Server 2008. What? Even the Microsoft PowerShell Team Blog never actually wrote a post announcing the PowerShell 2.0 release is available for download but instead wrote about the Windows Management Framework being released.

But in any case, I’m calling on the blogging community to fix the search engines by linking Windows PowerShell and particularly “Windows PowerShell 2.0”: http://support.microsoft.com/kb/968929 to either the Knowledge base article 968929 which has the download links for PowerShell 2.0 for Windows XP, Vista, and Server 2003 and 2008 … or to Microsoft.com/PowerShell which has the latest download links in the side-column on the right hand side. :)

I can’t fix the search engines on my own, but what was that slogan? Together we can!

Posted By: Xenophane
Last Edit: 30 Nov 2009 @ 21:30

EmailPermalinkComments (0)
Tags
Tags:
Categories: Tech Stuff
 20 Sep 2009 @ 9:40 

There has been some speculation on the web regarding the ADMGS for Server 2008 and 2003, if it would be possible to use it, in an environment without at least one Server 2008 R2.

So I decided to test it, I built a Server 2003 Domain, comprised of a single 2003 R2 Domain Controller, and 1 Windows 7 Enterprise workstation.
I installed Server 2003 into a VM, installed all updates inlcuding SP2, I then ran DCpromo to setup the new domain. When that was complete I downloaded the 2 required patches for 2003, to be able to run ADMGS.
(NDP35SP1-KB969166-x86.exe and 376193_ENU_i386_zip.exe), where the last of the two patches requires registration to download.

When they were installed, I downloaded the ADMGS setup file (Windows5.2-KB968934-x86.exe).
I created a few users, and everything worked fine.

I then built a Windows 7 client, downloaded the RSAT for Win 7 and joined it to the domain. I then ran my Powershell script to enable all RSAT tools on the machine.

The first thing I tried out was the new Active Directory Administrative Center, the new AD manament GUI built on Powershell, it connected to the DC, and I searched for the users I had created, and they showed up **SUCCESS**
I played around with it some more, creating/deleting some users, and everything seemed to work fine, so I tried out the “Active Directory Module for PowerShell”, pulling down some information about users and computers which also worked.

So all in all it seems as if it is not required to have a Server 2008 R2 in you domain/forest in order to use ADWS (Active Directory Web services) in your domain.

So there you have it folks, there are now a full live competitor to the Quest AD cmdlets, which have been around for a while and have let you manage you 2003 AD… Let the fight begin :)

Posted By: Xenophane
Last Edit: 20 Sep 2009 @ 09:42

EmailPermalinkComments (1)
Tags
Tags: , ,
Categories: Tech Stuff
 19 Sep 2009 @ 16:45 

Yesterday I was doing some maintenance on a machine at work, and when I looked in device manager, i saw that it was a Hyper-V guest machine, and I asked a few colleagues about it, because I was pretty sure that we didn’t have any machines running Hyper-V.. So I needed to find out which machine, so I wrote a quick and dirty PowerShell script to find it.

First off I knew that it had to be a Windows 2008 machine, that boiled down the possible machines quite a lot.

Here is what I did

Get-QADComputer | Where {$_.OSname -match "2008"} | % { Get-Service -ComputerName $_.Name} | where {$_.Displayname -match "hyper"} |  select  Machinename, Displayname

I get all computers that are Windows server 2008, and for each server 2008, I look for services containing the word “hyper”.
This is not a very efficient search, but a quick and dirty way to find the info that I needed.

—-EDIT—–

Kirk Munro pointed out to me that Hyper-V actually registers a SCP (Service Connection Point) in AD, so instead of querying all the machines, you can just query the list of SCP’s in AD instead, which is much more efficient.

Get-QADObject -Name 'Microsoft Hyper-V' -Type serviceConnectionPoint | Get-QADComputer -Identity {$_.ParentContainerDN}
Posted By: Xenophane
Last Edit: 25 Sep 2009 @ 20:38

EmailPermalinkComments (0)
Tags
Tags:
Categories: Tech Stuff
 14 Sep 2009 @ 13:41 

I have just upgraded my machines to Windows 7 RTM, before I did the reinstall I did full backup of my old Vista machines, of course I figured out that I had not gotten all the files out of the Vista machines before I upgraded, So I had to restore some files from the resulting .vhd backup images. But when I started Windows 7 restore, it did not recognize the backup folders.. So I thought I would just mount the vhd backup files manually, by going into Computer Management -> Disk management. But after having done that a few times, I thought it was too much hassle, so I decided to write a little PowerShell script to mount the vhd files for me.

# PowerShell function to create a script file for diskpart
# and the execute diskpart with the scriptfile
function Mount-Vhd {param([String]$InputFile)
"SELECT VDISK FILE=""$InputFile""" + "`r`n" + "ATTACH VDISK" | Out-File $env:TEMP\Mountvhd.txt -Encoding "ASCII"
Invoke-Expression -Command "Diskpart.exe /s $env:TEMP\Mountvhd.txt"
}
Mount-Vhd $args[0]

The above script has to be saved as “Mount-vhd.ps1″

But I wanted something even more simple, I just wanted to be able to right-click a .vhd file and choose open, so I created this little .reg file, that will allow you to right click a .vhd file and choose open.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.vhd]

[HKEY_CLASSES_ROOT\.vhd\shell]
@=”Open VHD”

[HKEY_CLASSES_ROOT\.vhd\shell\Open VHD]
@=”Open &VHD”

[HKEY_CLASSES_ROOT\.vhd\shell\Open VHD\command]
@=hex(2):22,00,43,00,3a,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,5c,\
00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,57,00,69,00,6e,00,\
64,00,6f,00,77,00,73,00,50,00,6f,00,77,00,65,00,72,00,53,00,68,00,65,00,6c,\
00,6c,00,5c,00,76,00,31,00,2e,00,30,00,5c,00,70,00,6f,00,77,00,65,00,72,00,\
73,00,68,00,65,00,6c,00,6c,00,2e,00,65,00,78,00,65,00,22,00,20,00,2d,00,57,\
00,69,00,6e,00,64,00,6f,00,77,00,53,00,74,00,79,00,6c,00,65,00,20,00,68,00,\
69,00,64,00,64,00,65,00,6e,00,20,00,2d,00,66,00,69,00,6c,00,65,00,20,00,22,\
00,63,00,3a,00,5c,00,74,00,6f,00,6f,00,6c,00,73,00,5c,00,4d,00,6f,00,75,00,\
6e,00,74,00,2d,00,76,00,68,00,64,00,2e,00,70,00,73,00,31,00,22,00,20,00,22,\
00,25,00,31,00,22,00,00,00

When you import the file, all the hex values are converted back to ascii chars, which you can see under [HKEY_CLASSES_ROOT\.vhd\shell\Open VHD\command] of course

Here is what will be written:

“C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe” -WindowStyle hidden -file “c:\tools\Mount-vhd.ps1″ “%1″

As you can see it expects the Mount-Vhd powershell file to be located in C:\tools\ in order to work. I have so far not been able to make it work, without referencing the file directly.

But when you have imported the .reg file, you can just navigate to [HKEY_CLASSES_ROOT\.vhd\shell\Open VHD\command] and change the path to anything you like.

You can download both files from here: http://xipher.dk/Tools/ImportVHDsettings.zip

Posted By: Xenophane
Last Edit: 14 Sep 2009 @ 13:44

EmailPermalinkComments (0)
Tags
Tags: , ,
Categories: Tech Stuff
 15 Aug 2009 @ 19:30 

They have gone back and tagged all the scripts they have made during the last many years, and put up an easily searchable repository on their site on Technet.

They are calling it the Script Gallery

You can sort scripts now by:
o Category
o Affiliation (Microsoft or community)
o Script language
o Supported platforms
o Tags
o Recently added
o Highest ranked
o Most active
o Most active (last seven days)
o When published
o Title (A-Z)
o Title (Z-A)
o Ranking
o Ranking (last seven days)
o Author (A-Z)
o Author (Z-A)

Posted By: Xenophane
Last Edit: 15 Aug 2009 @ 19:31

EmailPermalinkComments (0)
Tags
Categories: Everyday, Tech Stuff

 Last 50 Posts
 Back
Change Theme...
  • Users » 159
  • Posts/Pages » 101
  • Comments » 73
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

Links



    No Child Pages.

Books



    No Child Pages.

Ønsker



    No Child Pages.

CV



    No Child Pages.