Add to Technorati Favorites
Welcome to ThePowerShellGuy.com Sign in | Join | Help

Discovering PowerTab V2 series Part 1 : Installation or upgrade from V1

Last post there was a question on how to upgrade From the previous version of PowerTab Jason already answered in the comments.

As I also had this planned as start of this series I explain a bit more, while I’m installing the new current version PowerTab 0.99.5.

To startup the PowerTab V1 installation added this block to the Profile ( Tip use ii $profile to open your profile)

:

################ Start of PowerTab Initialisatie Code ########################
#
#  added to Profile by PowerTab Setup For Loading of Custom TabExpansion,
#
# /\/\o\/\/ 2007
#
#
http://ThePowerShellGuy.com
#

# Initialize PowerTab

& 'C:\Powertab\Init-TabExpansion.ps1' `

         -ConfigurationLocation 'C:\Users\morsouw.WW\Documents\WindowsPowerShell'

################ End of PowerTab Initialisatie Code ##########################

To disable PowerTab V1 we just remark out, to clean up a bit but keep the old version available I changed it like this :

# Old PowerTab

#& 'C:\Powertab\Init-TabExpansion.ps1' `
#     -ConfigurationLocation 'C:\Users\morsouw.WW\Documents\WindowsPowerShell'

Then we are ready to install, from here it is the same as the normal installation

I downloaded PowerTab-0.99.5.1.zip from http://powertab.codeplex.com/ and

* Important *

unblocked the ZIP file by right clicking it in Explorer –> properties –> Unblock

and extracted it, in the Zipfile there is a folder named PowerTab that you have to copy in your modules directory *documents\WindowsPowerShell\Modules.

tip you can easy open by using ii ( Split-Path $profile )

After that the installation is as simple as importing the module :

Import-Module powertab

Then the setup wizard will start (in 0.99.5 you can get the error The term 'Parse-Manifest' is not recognized as the name of a cmdlet, function, script file, or operable program, this can safely be ignored and will be fixed in next build) and create configuration file,( the working is described in the Documentation on Codeplex here Creating a Configuration File )

This setup still looks like the old setup and the easies way to configure Powertab is just hit enter till you see :

PowerTab version 0.99.5.1 PowerShell TabExpansion Library
Host: ConsoleHost
PowerTab Enabled: True

And ready !

* Update * It can be that the setup is not updating the profile, as can be seen in the setupinfo, a command like this will be added to the profile :

Import-Module "PowerTab" -ArgumentList "C:\Users\morsouw.WW\Documents\WindowsPowerShell\PowerTabConfig.xml"

 For now you have to copy that from the console into your profile by hand, of course in later version the setup will do this

But if you follow the setup information you find out that there is an extra option to store the Powertab config and database in Isolated Storage

Where should the PowerTab configuration file and database be saved?
Any existing PowerTab configuration will be overwritten.
[P] Profile Directory  [I] Installation Directory  [A] Application Data Directory  [S] Isolated Storage
[O] Other Directory[?] Help (default is "P"):

Detail information about the PowerTab configuration you can find here :

http://powertab.codeplex.com/documentation

a good place to start next.

and to see what functions are added by PowerTab V2 type :

Get-Command -Module powertab

Powertab V2 up and running, hence target of this post reached, more about the usage of PowerTab in the next part of this series, till then, when your new to PowerTab,  just hit Tab every time you think you might need completion and most of the time it will work ;)

And else take a look at the posts about Posts about PowerTab for PowerShell V1 on my blog, everything there still works (or is improved)

More about what is new in next post

Enjoy,

Greetings MOW

Posted by MoW | 2 Comments

PowerTab for PowerShell version 2.0 beta released on CodePlex

After a long silence, a grand new version of PowerTab is there !

With thanks to Jason Archer who took up the job and converted PowerTab to a PowerShell V2 Module.

Next to that, he fixed the issues with PowerTab on V2.0 and made some fabulous additions to PowerTab too !

You can find PowerTab on Codeplex now : http://powertab.codeplex.com/

I’m using Jason’s version for the last weeks and do not want to go back, as some very annoying issues with PowerTab on V2.0 are fixed and I really love the new functionality, so if you are a PowerTab user and are on PowerShell V2.0, I recommend to upgrade as soon as possible to this new version, it is still in Beta and testers are wanted ( please use issue tracker on CodePlex to provide bug reports or other input), but it is much better already as my old version and everything works the same or better, hence also for normal daily usage I recommend :

Upgrade as soon as Possible ! 

Jason did an amazing Job.

I will follow up with a series about using PowerTab and the new features.

Enjoy,

Greetings /\/\o\/\/

 

Posted by MoW | 7 Comments

MSDN content from PowerShell using WDSL

When I saw this post : MSDN content is also available as a Web service 

Of course I had to try this in PowerShell

The following code I came up with while testing will get the title of the following post http://msdn.microsoft.com/en-us/library/aa973757(VS.85).aspx :

 

$msdn = New-WebServiceProxy http://services.msdn.microsoft.com/ContentServices/ContentService.asmx?wsdl
$cr = New-Object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1vices_ContentService_asmx_wsdl.getContentRequest
$cr.contentIdentifier = 'aa973757'
$rd = new-object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1vices_ContentService_asmx_wsdl.requestedDocument
$rd.selector = 'Mtps.Xhtml'
$cr.requestedDocuments  = $rd
$cr.locale = 'de-de'
$msdn.GetContent($cr).primaryDocuments[0].any.div.div[0].'#text'
$cr.locale = 'en-US'
$msdn.GetContent($cr).primaryDocuments[0].any.div.div[0].'#text'

The Output looks like this :

PS > $cr.locale = 'de-de'
PS > $msdn.GetContent($cr).primaryDocuments[0].any.div.div[0].'#text'
Erste Schritte mit Windows PowerShell
PS > $cr.locale = 'en-US'
PS > $msdn.GetContent($cr).primaryDocuments[0].any.div.div[0].'#text'
Windows PowerShell Getting Started Guide

This if of course only a proof of concept, but would be cool to add online help this way to PowerShell or PowerTab (an excelent help with using Webservices, update-TabexpansionType after loading the webservice and you can tabcomplete the autogenerated types look here http://powertab.codeplex.com/ for the latest version for PowerShell V 2.0 )

try for example this :

$cr.contentIdentifier = 'aa394435'
$msdn.GetContent($cr).primaryDocuments[0].any | fc
$msdn.GetContent($cr).primaryDocuments[0].any.div[2].p

Enjoy, 

Greetings MOW

* Update * Of course I was not the only one with this idea, a much advanced example you can find here : http://poshcode.org/1724

Posted by MoW | 1 Comments
Filed under: ,

Replace security on existing share with WMI in PowerShell (update post)

This is an update of the script from my old Blog /\/\o\/\/ PowerShelled: Replace Security on existing share using MSH to PowerShell V2, I came at this post while recourcing a question about translating a SID, that I tested a lot with on my old blog see also the other posts about this here where you can find more examples.

As I was at it I rewrote the existing script to work in PowerShell V2

Changes,

  • Changed MshObject to PsObject (name change after Beta)
  • Added CreateInstance() to create the Abstract WMI Classes (seems that that was not needed before WMI wrapper was added in RC1)
  • By testing I found out that the script also did work with SID in string form now, before I could not get it working

Of course this script is also a candidate for further refactoring to an advanced function ( for example to check the value for mode if it is valid), but thats might be for a followup post.

# Set-SharePermission function
# Sets the security of a existing Share
# /\/\o\/\/ 2005-2010

Function set-Sharepermissions {
  PARAM (
    $share = "Test"
    $user = "administrators"
    $Domain = $null
    $mode = "Change"
  )

  $sd = (new-object management.managementclass Win32_SecurityDescriptor).CreateInstance()
  $ace = (new-object management.managementclass Win32_ace).CreateInstance()
  $Trustee = (new-object management.managementclass win32_trustee).CreateInstance()

  $Account = new-object system.security.principal.NtAccount($user)
  $SID = $Account.translate([system.security.principal.securityidentifier])
  #[byte[]]$ba = ,0 * $sid.BinaryLength
  #$sid.GetBinaryForm($ba,0)

  $Trustee.Domain = $Domain
  $Trustee.Name = $user
  #$Trustee.SID = $ba
  $Trustee.SIDString = $sid.Value

  switch ($mode) {
    "Full"   {$ace.AccessMask = 2032127}
    "Change" {$ace.AccessMask = 1245631}
    "Read"   {$ace.AccessMask = 1179817}
  }

  $ace.AceType = 0
  $ace.AceFlags = 3
  $ace.trustee = $trustee
  $SD.DACL = @($ACE.psobject.baseObject)

  $share = get-wmiObject win32_share -filter "name='$share'"

  $inparams = $share.GetMethodParameters("setShareInfo")
  $inParams["Access"]  =  $SD.psobject.baseObject

  $share.invokemethod("setshareInfo",$inparams,$null)
}

 On my old blog you can also find another post : /\/\o\/\/ PowerShelled: PowerShell Import Shares and Security info ... to complely export and import a complete share complete with security.

With the example in this post you should also be able to get that sample working again. 

Enjoy,

Greetings /\/\o\/\/

 

Posted by MoW | 2 Comments
Filed under: ,

Back again !, Kudos to OrcsWeb and 4th PowerShell Scriptclub in Zurich

Hi readers,

First of all, sorry for this second longer outage of my blog and the low post rate lately, especialy for the downtime.

Some explaination might be in order for that

About the outage, after the first time when my Dutch registrar went broke, this time the reason was a SQL Database that went over limit some time ago, for some reason or another Community server did eat a lot of space extra at a sudden (more as 200 MB).So something had to have happened that I needed to look at, but it also meant that I went over my free OrcsWeb MVP account limit.

I "hot fixed" that by paying for the extra space (actually a couple of times), till I could look in to it, but as Steve Schofield was so kind at the time to set Community Server up for me after that I had no problems before this moment, I was more or less an end user in this case and next to a time problem, so I did not had a clue where to look was busy and so kept postponing the problem.

Till a lot of things happened at the same time: 

  • my "Old" Dutch mail address that I kept for a year after moving to Switzerland got disabled.
  • I had not changed me contact address 
  •  ...missed the mails from OrcsWeb...
  • Was busy 
  • had a little vacation..  
  • came back
  • I had a lot of people asking me where by blog was. 
  • Busy. 
  • had no invoices, so no access to the invoice number...

So I finally did what I had to do in the first place, I called OrcsWeb , I explained the problem and :

  • Within 15 Minutes my blog was up
  • Sometime later I got an email that they changed my account details
  • A mail with updated login for new mail address
  • And when I just did look at the Database space, it was under the limit !

So for the second time, they also helped me out getting my blog online again after I lost my Domain registration and now, on an issue that was outside of their responsibility, next to all the other awesome support they have given me over the year, especially Steve at the time he worked at OrcsWeb as mentioned above, but this goes for all the people at OrcsWeb I had contact with.   

I do not know yet what the problem was but awesome Service on an otherwise free MVP hosting plan, Hence kudos to  OrcsWeb , and blame on me for forgetting this and not shouting for help earlier.

For the low posting rate, I still very busy with PowerShell at my new company WinWorkers , I'm working on some very cool solutions in the System Center area at the moment and of course this contains a lot of PowerShell ;), be sure to hear more about this soon !, and a lot of Exchange scripting in a big migration project.

And I did speak at lot of events in Switzerland as GeekMania , and events with the Swiss IT Pro User Group  I joined as the Microsoft evolution Day , and the PowerShell scriptclubs .

The fourth PowerShell ScriptClub in Zurich will already be next week the 1st of June, for more information and to register click here.

Hope to see you there ! 

Greetings /\/\o\/\/

Posted by MoW | 6 Comments

Scripting Games 2010

The Scripting Games are coming again, click on the 2010 Scripting games badge below for more info :

2010 Scripting Games

Hope to see you there ! 

Enjoy,

Greetings /\/\o\/\/

 

 

Posted by MoW | 1 Comments

DPM 2010 RC1 Extended Tweet

<ExtendedTweet>

Grr, getting bored of typing that servername every time with DPM Cmdlets

For now some helper fuctions :

function Get-ProtectionGroup {Microsoft.DataProtectionManager.PowerShell\Get-ProtectionGroup (hostname)}
function Get-Datasource {Microsoft.DataProtectionManager.PowerShell\Get-Datasource (hostname)}

… …

But I think this Calls for some advanced functions, proxyCmdlet’s, (or a late  bugfix ;) ) that it defaults to local server, only if it is a DPM server, and makes it possible to use the parameters.

<\ExtendedTweet>

Might eventually turn into a complete blog post

Enjoy,

Greetings /\/\o\/\/

Posted by MoW | 1 Comments

Next PowerShell Script Club in Zurich March 2

Next Month the 2nd of March  there is a PowerShell scriptclub in Zurich again.

For more information or to register :

http://www.digicomp.ch/sitpug

 

Enjoy,

Greetings /\/\o\/\/

Posted by MoW | 0 Comments
Filed under: ,

PowerShell Script Club in Zurich

Next week I will at the Swiss IT Pro User Group Event 3.Nov 2009 Zurich - PowerShell Script Club

The first PowerShell Scriptclub in Zurich, with thanks to Desmond Lee , the Swiss IT Pro User Group and Digicomp Academy AG  (Zürich)

Below the excerpt from the newsletter (the Dunglish is mine, sorry we had to be quick ) :

Swiss IT Pro User Group Events - Di./Tu. 3 Nov. 2009
    by IT Pros for IT Pros
    Subject:    PowerShell Script Club
    Language:  English
    Tue / Dienstag - 3. Nov 2009
    17:45 - 21:00 Uhr
    Kleiner Apéro 17:45 - 18:15 Uhr und ab 2015 Uhr
    Where / Wo?
Digicomp Academy AG  (Zürich)
        Limmatstrasse 50
        CH-8005 Zürich
        Tel. +41 44 447 21 21

  With thanks to the Swiss IT Pro User Group and Digicomp, the first
  Zurich PowerShell Script Club will be held in Zurich next week Tuesday.
  This Scriptclub will be led by Marc van Orsouw (aka /\/\0\/\/ or
  the PowerShell Guy). Welcome Marc to our Swiss IT Pro User Group family!
       Referat:
        Marc van PowerShell is a Dutch but living in Switzerland and is a
        PowerShell MVP for the last 4 years in a row, he is best known for his
        blog
thePowerShellGuy.com and his utilities for PowerShell as PowerTab
        and the PowerShell WMI explorer.
       Session:  What is a PowerShell Script Club?
            Script Clubs are like a hands on lab with no set topic or teacher. You bring
            an idea for a script, and ask your fellow PowerShell users for help getting
            the script written.
            Script Club is a great way to learn PowerShell.
            Join the PowerShell Script Club today!
            Beginner through Advanced users equally welcome.
         * computers with PowerShell V2 installed may be available.
       -------------
    IMPORTANT REGISTRATION INFO
        -------------
    Important event registration (it's free) and detail session information
here.

Hope to see you next week !

Enjoy,

Greetings /\/\0\/\/

Posted by MoW | 2 Comments

Microsoft Evolution Day

At 3 December I will be giving a PowerShell session at the Microsoft Evolution Day in Zurich,

Microsoft Evolution Day

Windows 7, Windows Server 2008 R2, Office Communication Server 2007 R2, Exchange 2010, Office 2010, SharePoint 2010, PowerShell 2.0 – die Evolution der Microsoft Lösungen geht rasend schnell. Am Microsoft Evolution Day vom 3. Dezember 2009 werden alle neuen Produkte live vorgestellt. Die optimale Gelegenheit für IT Professionals sich den Überblick zu den Neuerungen aus Redmond zu verschaffen.

 

 

For more information or to register see : http://www.digicomp.ch/MicrosoftEvolutionDay

Hope to see you there.

Enjoy,

Greetings /\/\0\/\/

Posted by MoW | 1 Comments
Filed under:

PowerShell Programming Praxis: Nerds, Jocks, and Lockers

And another WTF Programing Praxis :

Nerds, Jocks, and Lockers

 function get-OpenLockers ($num){1..([math]::sqrt($num))|%{$_*$_}}

Enjoy,

Greetings /\/\o\/\/

Posted by MoW | 0 Comments
Filed under:

PowerShell Programming Praxis: Josephus' Circle

And another PowerShell excersise from the WTF  (Worse than Failure) contest  Programming Praxis: Josephus' Circle . (for more info see original contest post)

 Function get-SafeSpot ($count,$Skip) {
  $q = [Collections.queue](1..$count)
  while ($q.count -gt 1){
    1..($skip-1) |% {$q.enqueue($q.dequeue())}
    [void]$q.dequeue()
  }
  $q
}

By using a Queue (that works on a FIFO (First In First Out) base, I could keep the loop very simple by just requeueing the surviving members) and could save me the Math otherwise involved in keeping count.

Enjoy,

Greetings /\/\o\/\/

Posted by MoW | 0 Comments
Filed under:

PowerShell : Display a GUID as string by default

When you have a GUID object in PowerShell by default this gives no output, only some empty lines.

See output below :

PS C:\> [GUID]$a = "00000000-0000-0000-0000-000000000000"                                                               
PS C:\> $a                                                                                                              
                                                                                                                        
                                                                                                                        
                                                                                                                        
PS C:\> $a.ToString()                                                                                                   
00000000-0000-0000-0000-000000000000                                                                                    
PS C:\> "$a"                                                                                                            
00000000-0000-0000-0000-000000000000                                                                                    
PS C:\> Update-TypeData C:\MowTemp\GUID.ps1xml                                                                          
PS C:\> $a                                                                                                              
                                                                                                                        
GUID                                                                                                                    
----                                                                                                                    
00000000-0000-0000-0000-000000000000                                                                                    
                                                                                                                        
                                                                                                                        

The reason for this is that a GUID has no properties only 2 Methods to show the value of the GUID

ToByteArray()
ToString()

one option is Embedding it in a string "$a" 

But as it is handy to show the GUI as string by default I created the following TypeData file that adds a GUID property to the GUID object so that the string value is Shown by default in PowerShell as in the second example above after the TypeData file is loaded

the TypeData file looks like this :

<?xml version="1.0" encoding="utf-8" ?> 
<Types> 
    <Type> 
        <Name>System.Guid</Name> 
        <Members> 
            <ScriptProperty>
                <Name>GUID</Name>
                 <GetScriptBlock>
                    $this.Tostring()
                </GetScriptBlock>
            </ScriptProperty> 
        </Members> 
    </Type> 
</Types>

Democracy to the Types ! 

Enjoy,

Greetings MOW

Posted by MoW | 1 Comments
Filed under: ,

Russian Peasant Multiplication

Small PowerShell exercise taken from the Programming Praxis: Russian Peasant Multiplication contest of WTF (Worse than Failure) implementing the Russian Peasant Multiplication method (for more info see original contest post)

function Invoke-RussianMultiply ([int]$a,[int]$b)
{
  "$a x $b"
  $r = 0
   while($a -ne 1){
     $a = $a/2
     $b = $b*2
     "$a x $b"
     if ($a%2) {$r+=$b;"`t+$b"}
   }
  "result : $r"
}
 

The result looks like this :

PS C:\> Invoke-RussianMultiply 18 23                                                                                    
18 x 23                                                                                                                 
9 x 46                                                                                                                  
        +46                                                                                                             
4 x 92                                                                                                                  
2 x 184                                                                                                                 
1 x 368                                                                                                                 
        +368                                                                                                            
result : 414                                                                                                            

 

Enjoy,

Greetings /\/\o\/\/

Posted by MoW | 2 Comments
Filed under:

Get-Scripting Podcast Episode 11 - (MoW aka the PowerShell Guy)

I had the pleasure to be interviewed for the Get-Scripting Podcast

You can find the show here :

Get-Scripting Podcast Episode 11 - (MoW aka the PowerShell Guy)

 

Enjoy,

Greetings /\/\o\/\/

Posted by MoW | 0 Comments
More Posts Next page »