Wednesday, June 11, 2008
format test
if ($CreateDvdDrive.ispresent) {
CreateDvdDrive $vmname
}
else {
if ($emptyOnly.ispresent) {
mount-iso $vmname $emptyiso
}
elseif ($vmconfigonly.ispresent) {
mount-iso $vmname $iso
}
else {
# remount
mount-iso $vmname $emptyiso
mount-iso $vmname $iso
}
}
if ($CreateDvdDrive.ispresent) {
CreateDvdDrive $vmname
}
else {
if ($emptyOnly.ispresent) {
mount-iso $vmname $emptyiso
}
elseif ($vmconfigonly.ispresent) {
mount-iso $vmname $iso
}
else {
# remount
mount-iso $vmname $emptyiso
mount-iso $vmname $iso
}
}
1: if ($CreateDvdDrive.ispresent) {
2: CreateDvdDrive $vmname 3: }4: else {
5: 6: if ($emptyOnly.ispresent) {
7: mount-iso $vmname $emptyiso 8: }9: elseif ($vmconfigonly.ispresent) {
10: mount-iso $vmname $iso 11: }12: else {
13: # remount
14: mount-iso $vmname $emptyiso 15: mount-iso $vmname $iso 16: } 17: }
1: if ($CreateDvdDrive.ispresent) {
2: CreateDvdDrive $vmname 3: }4: else {
5: 6: if ($emptyOnly.ispresent) {
7: mount-iso $vmname $emptyiso 8: }9: elseif ($vmconfigonly.ispresent) {
10: mount-iso $vmname $iso 11: }12: else {
13: # remount
14: mount-iso $vmname $emptyiso 15: mount-iso $vmname $iso 16: } 17: }Monday, March 03, 2008
test
Will be deleted shortly
Wednesday, February 13, 2008
Code Snippet plugin for Windows Live Writer
Thank you Leo Vildosola! You just made me a very happy blogger :)
I found your plugin for Windows Live Writer and it works great with PowerShell scripts. Inserting well-formatted, color-codedPowerShell code is now as easy as selecting 'Insert Code Snippet', pasting the code and pressing ok. There are only two drawbacks -
- Is is not copy-friendly, as there are no line breaks. But my current method is not that either
- The formatting is called MSH and not PowerShell, but I think I can live with that ;)
Some examples
With line numbers and a container
1: # Set-SMSCacheSize
2: param([int]$newSizeInMB=2000)
3: 4: $sms=new-object -com UIResource.UIResourceMgr 5: $ci=$sms.GetCacheInfo()6: if ($ci.TotalSize -ne $newSizeInMB) {
7: $ci.TotalSize=$newSizeInMB8: "Size set to $newSizeInMB"
9: }10: else {
11: "Size $newSizeInMB already correct"
12: }
Alternating lines, no container, no line numbers -
# Set-SMSCacheSizeparam([int]$newSizeInMB=2000)$sms=new-object -com UIResource.UIResourceMgr
$ci=$sms.GetCacheInfo()
if ($ci.TotalSize -ne $newSizeInMB) {
$ci.TotalSize=$newSizeInMB
"Size set to $newSizeInMB"}
else { "Size $newSizeInMB already correct"}
No line numbers, no container
# Set-SMSCacheSize
param([int]$newSizeInMB=2000)
$sms=new-object -com UIResource.UIResourceMgr
$ci=$sms.GetCacheInfo()
if ($ci.TotalSize -ne $newSizeInMB) {
$ci.TotalSize=$newSizeInMB
"Size set to $newSizeInMB"
}
else {
"Size $newSizeInMB already correct"
}
No line numbers, no container, alternating lines
# Set-SMSCacheSizeparam([int]$newSizeInMB=2000)$sms=new-object -com UIResource.UIResourceMgr
$ci=$sms.GetCacheInfo()
if ($ci.TotalSize -ne $newSizeInMB) {
$ci.TotalSize=$newSizeInMB
"Size set to $newSizeInMB"}
else { "Size $newSizeInMB already correct"}
No line numbers, container, alternating lines
# Set-SMSCacheSizeparam([int]$newSizeInMB=2000)$sms=new-object -com UIResource.UIResourceMgr
$ci=$sms.GetCacheInfo()
if ($ci.TotalSize -ne $newSizeInMB) {
$ci.TotalSize=$newSizeInMB
"Size set to $newSizeInMB"}
else { "Size $newSizeInMB already correct"}
test3
# Format SDDL strings in a more readable format
# If -TranslateSid is present, Sids will be translated to their account equivalent
param([switch]$translateSid)
process {
$sddl=$_
if ($sddl -is [string]) {
# Simply use the value
}
else {
# If input is any thing else, pick up SDDL property
# This makes it possible to pipe in the output from Get-Acl or Select
$sddl=$_.sddl
}
# Insert linefeed before G: D: or S: blocks
# Insert linefeed and indent values in ()
$sddl=$sddl -replace "([GDS]):","`n`$1:" -replace "(\([^\)]+\))","`n `$1"
if ($translateSid.isPresent) {
# Match all SIDs and translate them to NTAccount format
[regex]::Matches($sddl,"(S(-\d+){2,8})") | sort index -desc | % {
# Save value in case translatation fails
$name=$_.value
$sid=[system.security.principal.securityidentifier] $name
# Remove matched value
$sddl=$sddl.remove($_.index,$_.length)
# Translate, suppress non-translatable exception
trap [System.Management.Automation.MethodInvocationException] {continue} `
$name=$sid.Translate([system.security.principal.ntaccount])
# Insert translated name
$sddl=$sddl.insert($_.index,$name)
}
}
$sddl
}
# Format SDDL strings in a more readable format
# If -TranslateSid is present, Sids will be translated to their account equivalent
param([switch]$translateSid)
process {
$sddl=$_
if ($sddl -is [string]) {
# Simply use the value
}
else {
# If input is any thing else, pick up SDDL property
# This makes it possible to pipe in the output from Get-Acl or Select
$sddl=$_.sddl
}
# Insert linefeed before G: D: or S: blocks
# Insert linefeed and indent values in ()
$sddl=$sddl -replace "([GDS]):","`n`$1:" -replace "(\([^\)]+\))","`n `$1"
if ($translateSid.isPresent) {
# Match all SIDs and translate them to NTAccount format
[regex]::Matches($sddl,"(S(-\d+){2,8})") | sort index -desc | % {
# Save value in case translatation fails
$name=$_.value
$sid=[system.security.principal.securityidentifier] $name
# Remove matched value
$sddl=$sddl.remove($_.index,$_.length)
# Translate, suppress non-translatable exception
trap [System.Management.Automation.MethodInvocationException] {continue} `
$name=$sid.Translate([system.security.principal.ntaccount])
# Insert translated name
$sddl=$sddl.insert($_.index,$name)
}
}
$sddl
}
test2
# Format SDDL strings in a more readable format
# If -TranslateSid is present, Sids will be translated to their account equivalent
param([switch]$translateSid)
process {
$sddl=$_
if ($sddl -is [string]) {
# Simply use the value
}
else {
# If input is any thing else, pick up SDDL property
# This makes it possible to pipe in the output from Get-Acl or Select
$sddl=$_.sddl
}
# Insert linefeed before G: D: or S: blocks
# Insert linefeed and indent values in ()
$sddl=$sddl -replace "([GDS]):","`n`$1:" -replace "(\([^\)]+\))","`n `$1"
if ($translateSid.isPresent) {
# Match all SIDs and translate them to NTAccount format
[regex]::Matches($sddl,"(S(-\d+){2,8})") | sort index -desc | % {
# Save value in case translatation fails
$name=$_.value
$sid=[system.security.principal.securityidentifier] $name
# Remove matched value
$sddl=$sddl.remove($_.index,$_.length)
# Translate, suppress non-translatable exception
trap [System.Management.Automation.MethodInvocationException] {continue} `
$name=$sid.Translate([system.security.principal.ntaccount])
# Insert translated name
$sddl=$sddl.insert($_.index,$name)
}
}
$sddl
}
test ps
# Format SDDL strings in a more readable format
# If -TranslateSid is present, Sids will be translated to their account equivalent
param([switch]$translateSid)
process {
$sddl=$_
if ($sddl -is [string]) {
# Simply use the value
}
else {
# If input is any thing else, pick up SDDL property
# This makes it possible to pipe in the output from Get-Acl or Select
$sddl=$_.sddl
}
# Insert linefeed before G: D: or S: blocks
# Insert linefeed and indent values in ()
$sddl=$sddl -replace "([GDS]):","`n`$1:" -replace "(\([^\)]+\))","`n `$1"
if ($translateSid.isPresent) {
# Match all SIDs and translate them to NTAccount format
[regex]::Matches($sddl,"(S(-\d+){2,8})") | sort index -desc | % {
# Save value in case translatation fails
$name=$_.value
$sid=[system.security.principal.securityidentifier] $name
# Remove matched value
$sddl=$sddl.remove($_.index,$_.length)
# Translate, suppress non-translatable exception
trap [System.Management.Automation.MethodInvocationException] {continue} `
$name=$sid.Translate([system.security.principal.ntaccount])
# Insert translated name
$sddl=$sddl.insert($_.index,$name)
}
}
$sddl
}
# Format SDDL strings in a more readable format
# If -TranslateSid is present, Sids will be translated to their account equivalent
param([switch]$translateSid)
process {
$sddl=$_
if ($sddl -is [string]) {
# Simply use the value
}
else {
# If input is any thing else, pick up SDDL property
# This makes it possible to pipe in the output from Get-Acl or Select
$sddl=$_.sddl
}
# Insert linefeed before G: D: or S: blocks
# Insert linefeed and indent values in ()
$sddl=$sddl -replace "([GDS]):","`n`$1:" -replace "(\([^\)]+\))","`n `$1"
if ($translateSid.isPresent) {
# Match all SIDs and translate them to NTAccount format
[regex]::Matches($sddl,"(S(-\d+){2,8})") | sort index -desc | % {
# Save value in case translatation fails
$name=$_.value
$sid=[system.security.principal.securityidentifier] $name
# Remove matched value
$sddl=$sddl.remove($_.index,$_.length)
# Translate, suppress non-translatable exception
trap [System.Management.Automation.MethodInvocationException] {continue} `
$name=$sid.Translate([system.security.principal.ntaccount])
# Insert translated name
$sddl=$sddl.insert($_.index,$name)
}
}
$sddl
}
Wednesday, November 07, 2007
Live Writer er fed
For nu kan jeg gøre lige det jeg vil, direkte - uden at skulle fedte rundt med bloggers interface.
Er lille snip
if { $blah -eq "snot") {
"hej"
}
Blah blah blah blahb
sadkfjasdfsd
- fdsaklfjsd fsdaf
- sadfjfkfjdas
- sadfjfk
fsakdjfj
param([switch]$basename)
$files=dir $(Get-VirtualGuestDirectories) *.vmc -recurse
if ($basename.isPresent) {
$files | % { $_.name -replace "$($_.extension)`$",""}
}
else {
$files
}
([switch]$basename)
$files=dir $(Get-VirtualGuestDirectories) *.vmc -recurse
if ($basename.isPresent) {
$files | % { $_.name -replace "$($_.extension)`$",""}
}
else {
$files
}
07\Library\test2.queue\Queue.Lock
E: Performing operation "Set Content" on Target "Path: C:\Users\po\Documents\Kunder\AP
07\Library\test2.queue\QueueItem_20071107152747.xml".
Remove-FileBasedLock: Closing C:\Users\po\AppData\Local\Temp\test.test
ocs\Kunder\APMM\LCS\test 20071107\Library> $sb
{$_}
ocs\Kunder\APMM\LCS\test 20071107\Library> $sb | add-queueitem test2.queue
Get-FileBasedLock: OpenOrCreate C:\Users\po\Documents\Kunder\APMM\LCS\test
07\Library\test2.queue\Queue.Lock
E: Performing operation "Set Content" on Target "Path: C:\Users\po\Documents\Kunder\AP
07\Library\test2.queue\QueueItem_20071107152821.xml".
Remove-FileBasedLock: Closing C:\Users\po\AppData\Local\Temp\test.test
ocs\Kunder\APMM\LCS\test 20071107\Library> tp ..\New-LCSAce.ps1
ocs\Kunder\APMM\LCS\test 20071107\Library>
ocs\Kunder\APMM\LCS\test 20071107\Library>
ocs\Kunder\APMM\LCS\test 20071107\Library>
ocs\Kunder\APMM\LCS\test 20071107\Library>
ocs\Kunder\APMM\LCS\test 20071107\Library> tp ..\Compare-ADWithLCS.ps1
ocs\Kunder\APMM\LCS\test 20071107\Library> cd ..
ocs\Kunder\APMM\LCS\test 20071107> copy .\Compare-ADWithLCS.ps1 Process-LCSItem.ps1
ocs\Kunder\APMM\LCS\test 20071107> tp .\Process-LCSItem.ps1
ocs\Kunder\APMM\LCS\test 20071107> cd .\Library
| fsd | fdsafsadfsafadsfsadffsdfsdfsdfsdfs fsda |
| fsda |
Labels: test
Tuesday, July 17, 2007
ps color
param([switch]$basename)
$files=dir $(Get-VirtualGuestDirectories) *.vmc -recurse
if ($basename.isPresent) {
$files | % { $_.name -replace "$($_.extension)`$",""}
}
else {
$files
}
powershell test
param([switch]$basename)
$files=dir $(Get-VirtualGuestDirectories) *.vmc -recurse
if ($basename.isPresent) {
$files | % { $_.name -replace "$($_.extension)`$",""}
}
else {
$files
}
Live Writer Beta 2 test
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 13-04-2007 23:14 1756 Invoke-Intellisense.ps1
18 _docs\WindowsPowerShell> dir . *ele* -re
Directory: Microsoft.PowerShell.Core\FileSystem::C:\Users\po\Documents\WindowsPowerShell\Library
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 04-07-2007 23:32 103 Start-ElevatedProcess.ps1
Directory: Microsoft.PowerShell.Core\FileSystem::C:\Users\po\Documents\WindowsPowerShell\PersistedFunctions
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 19-12-2006 08:23 650 find-DriveLetter.ps1
-a--- 05-12-2006 08:27 627 find-DriveLetter.ps1.cs
-a--- 05-12-2006 08:27 627 find-DriveLetter.ps1.java
-a--- 05-12-2006 08:27 627 find-DriveLetter.ps1.js
-a--- 05-12-2006 08:27 627 find-DriveLetter.ps1.jsl
Labels: test
Friday, April 27, 2007
test2
if ($a -eq "sfd") {
"hi"
}
else {
"dshifds"
"wwwwwwww"
}
test
Dette er en nem test
- a
- dfasfdas
- f
- as
- fdsf
- da
- afds
fasdfsadfsfsdfsad
f
sadf
sad
Friday, December 15, 2006
This is another test
fjkasl fsakældfj sæaldkjf sadlæfklsadjfsldajfælsadfjls
fsajdfklsafjalk
fasjkdljafsdfsd
klfsja dlfj sajfælksad jflasflsjadfæljsælfsadfjkslad jfslajfæsl dfklsædfjsædalfsdafklsdjflksds sdf sa fsda fsd fsda f sdaf sdf sag asdfg dfsa gafd a fs adf sdaf sdaf sda fsda fsd fsd af sf sdf sadf asf sad fsad fsa df asf
