Rename HyperV export for import (clone)

Scripts Send feedback »

When you have a Windows 2008 R2 machine and the HyperV role enabled but no SCVVM or whatever. Cloning is not possible out-of-the-box but you can create an export.

As soon as you want to import this export again you will get a message about the machine already exists. When you rename the vhd and replace all the references in the config files of the export you ARE able to import the machine again.

That's why I created a .ps1 script to list all the exports in the current folder and rename the choosen one.

Read more »

Attachments:

Powershell create Scheduled Tasks

Scripts 3 feedbacks »

Because I encountered a lot of strugle to create some scheduled tasks on a Windows 2003 machine with PowerShell v2.0.

I used the function of Hugo Peeters (see the link) and then I encountered a problem to pass a task with a parameter between double quotes.

Create-ScheduledTask -ComputerName $Server -TaskName '`"Name`"' -TaskRun '`"C:\WINDOWS\system32\cscript.exe \`"C:\test script\script.vbs\`"`"' -Schedule "DAILY" -StartTime "08:00" -RunAsUser "$domain\$User" -RunAsPwd $Password -Days "*"

This is the only format I used that worked to create a scheduled task to start a vbscript or another task including a parameter.

Read more »

Function IndexOfArray

Scripts Send feedback »

The only missing "simple" action or method on an array is to retrieve the index number representing a value. That's why I wrote this simple function:

# -----------------------------------------------------
Function IndexOfArray
{
param ([array]$x, [String]$y)
 $ItemIndex = 0
 If (!($x -contains $y)) {Return ""; Break}
 ForEach ($item in $x)
 {
  If ($y -eq $item) { Return $ItemIndex; Break}
  $ItemIndex++
 }
}
# -----------------------------------------------------

$arrDTAP = ("D", "T", "A", "P")
$IndexNumber = IndexOfArray $arrDTAP "T"
$IndexNumber

 

Windows PowerShell 2.0 RTM for WinXP/W2k3/W2k8/Vista

Scripts Send feedback »

Link: http://support.microsoft.com/kb/968929

Microsoft Released Windows Management Framework (Windows PowerShell 2.0, WinRM 2.0, and BITS 4.0) for Windows XP/ Windows Vista/ Windows 2003 and Windows 2008.

The RTM version of PowerShell 2.0 is the same version included in Windows 7 and Windows 2008 R2. 

Template script to use arguments from the command line [updated 24-12-2009]

Scripts, Admin Automation, Admin analyse Send feedback »

I had a lot of problems with making a failsafe script that forces the use of 'named' parameters from the commandline and give the posibility to show a help when not used correct. This is my solution and it is possible to use it as a template. See the test below or download the script itself from the attachment to have the proper indents.

Update: The template is updated because the error handling didn't work properly with the arraylist. Also some declarations are moved.

Read more »

Attachments:

Clean-ProfileSharev2.ps1

Admin Automation Send feedback »

This is my first script and I want to publish it to the world!!! Look at the Help file.

Everybody knows this problem. Especially in a large environment. You have a share with roaming or hybrid profiles. This share seems to grow exponentially. The thing that happens is the users are deleted/disabled because users are no longer working at the company or are no longer using the environment. So the profile is obsolete.

This script will move all the folders of disabled/deleted users into a subfolder _deleted or _disabled. This way you don't delete folder automated, because that's scary. But you have a single folder which you can backup and clean very easily.

Read more »

Attachments:

Started this Blogsite because...

Background 2 feedbacks »

Hi all,

Please let me introduce myself. I'm a consultant at a prominent Dutch consultancy company called Login Consultants. We are specialised in Virtualisation, Deploying and Server Based Computing. In enterprise environments and large mid-size company environments our goal is to automate everything that makes sense. PowerShell is a great tool to achieve that. Especially since Windows 2008 (R2) and Windows 7 are more and more accepted products. So PowerShell will be available everywhere very soon. ;-)

I started this Blog because I want to share my personal scripts with the rest of the community. There are a lot of sites and blogs for PowerShell and I hope to contribute with my scripts and bring something new. I hope to post a lot of how-to articles, depending on the reponse. But I want to publish a lot of ready-to-use scripts also. This Blogsite couldn't exist without me being a consultant at Login Consultants. It enables me by learning every day from excellent collegues. Special thanks to Floris van der Ploeg who taught me the basic in PowerShell.

Hope to see ya all back,

Mike Bijl

Contact. ©2012 by Mike Bijl. blog software.
Design & icons by N.Design Studio. Skin by Tender Feelings / Evo Factory.