Answered Add-PSSnapin Issue in PowerShell 2.0

  • יום רביעי 14 מרץ 2012 06:30
     
     
    I have just touched PS for less than a month and want to consult with you here a issue I came across currently.

    My bat script firstly calls a PS script "ps-1" to do some thing. "ps-1" will add a snap-in "A" firstly and then calls the PS script "ps-1-1", "ps-1-2" and "ps-1-3" subsequently. Each child script "ps-1-i"(i=1,2,3)also uses that snap-in “A”. In the current implementation, the child script will execute the "Add-PSSnapin" command in its own firstly in order to use it. Therefore, a lot of time is wasted on the "Add-PSSnapin“ action... So is there a way that the snap-in "A" is added once and all the subsequent child PS scripts can share the space?

    I am running the code on the Win2008-R2 OS with the Powshell V2.0 installed by default.

    Thank you in advance!
     

כל התגובות