powershell

Powershell WMI ROOT\MicrosoftExchangev2, and WQL where usage

(PS Version 1) PS C:\> $query = 'Select * From Exchange_PublicFolder WHERE Path LIKE "/Foo%"' PS C:\> $query Select * From Exchange_PublicFolder WHERE Path LIKE "/Foo%" PS C:\> gwmi -namespace ROOT\MicrosoftExchangev2 -query $query Get-WmiObject : Provider is not capable of the attempted operation At line:1 char:5 + gwmi <<<< -namespac...

PowerShell script packaging and WinNT execution?

Is there any free software to package a powershell script into a standalone WIN32 executable? It seems it was possible to get the powershell beta's to run on win2000 and winNT, is there any known way to get the final powershell to run on it? ...

How can I access Certificate ExtendedProperties using powershell?

If you open the properties window of a certificate in the certificate manager in windows you will see both a friendlyname and description field. I'm trying to get to the description field programatically via powershell. When accessing the certificates via powershell's certificate provider cert: you get an object that only exposes the F...

Calling Powershell Pretty Console Output from c#

Powershell has some pretty nifty formating modules for displaying objects, arrays, collections, dictionaries, and tabular data. Since Powershell is all .NET, I'm assuming there is a Assembly containing the logic for this. Who can come up with a way to call these powershell formating from .NET: I'd imagine something like this: Console...

powershell : what is wrong with this if get-childitem statement?

I'm having trouble getting this powershell statement to work. The objective is I'm trying to get a list of folders which are in ..\archive folder sorted by oldest to youngest. I would like to copy the number of folders which amount to or less than $ClosedJobssize from the ..\Archive to the ..\movetotape folder. This is so the size of...

Recycling IIS application pool using PowerShell: "Exception calling Recycle"

It looks like a recent windows update has broken some functionality I was using to recycle IIS6 application pools, as this has been working for months up to today. Exception calling "Recycle" : "Win32: The object identifier does not representException calling "Recycle" : "Win32: The object identifier does not represent a valid object. ...

How can I tell what WQL operators are supported on a class using powershell?

So the WQL LIKE operator isn't supported on my WMI class from this question. How do I tell ahead of time, or interactively as I write, what is/is not supported? I'd like to stick with Powershell here and avoid other solutions like wmic. ...

How to build an application on top of PowerShell?

Microsoft seems to be heavily pushing that their server applications (i.e SQL Server 2008, Exchange Server, etc) all have some type of PowerShell integration. The logic makes sense in that one can choose to manage the application from a GUI or CLI. Therefore if one were to follow that trend and want to build an application that had a P...

IE Automation with Windows PowerShell

Hey all. I want to ask about manipulating IE via Powershell. My goal is to write script that will automatically perform some actions in the browser (on the client side – navigate to page, perform actions, measure time between responses, etc.) I have this little thing: $ie = new-object -com "InternetExplorer.Application" $ie.visible =...

Automate Dual Monitor Setup In Vista

I use a laptop as my primary workstation. Sometimes I work alone on it, but a significant portion of the time, I'm at my office desk and I hook up an external monitor to increase my workspace. Every time I perform this action, I click the same dialog boxes in Windows Vista to setup the dual screen and position the window. It seems like ...

Why can't I access $args from inside a function?

Here is my code: # hi.ps1 function fun { Write-Host $args } Write-Host '---------------' Write-Host $args Write-Host '---------------' fun Write-Host '---------------' This is the output: PS C:\scratch> .\hi there jim --------------- there jim --------------- --------------- My question is, why isn't $args visible within fun...

powershell or msdeploy

I am running into a situation where I need to find a better approach to deploy web applications (asp.net to iis6..sorry ruby lovers :( and I was curious what some of you have done? I have seen products out there (Anthill?) but I am really looking for a way that my operations team can script a way to grab zip files (packaged code and asse...

What is the best way to program against powershell's x64 vs. x86 variability.

We have several scripts we use to install and configure the dependencies backing the systems we maintain. We run these anytime we establish a dev, test, demo, train, prod, etc. environment. We often find that we have to deal with x64 vs. x86 architecture, especially where the powershell scripts are concerned. For example, I have a scrip...

Adding digits of large integers in PowerShell

When adding the digits of a number in PowerShell, all is well with integers that have a length -le 29. $largeInteger = 11111111111111111111111111111 #29 digits sums correctly $sumDigits = 0 $largeInteger while ($largeInteger -ne 0) { $sumDigits += $largeInteger % 10 $largeInteger = [MATH]::Floor($largeInteger /10) } $sumDig...

powershell exchange 2003 : wmi-object does not pull all mailbox stores?

I have the following code pulling from my exchange server 2003. connect-qadservice -service 'localhost' foreach ($server in $exchangeservers) { $AllUsers += get-wmiobject -class Exchange_Mailbox -namespace Root\MicrosoftExchangeV2 -computername $server| select servername,storagegroupname, storename,mailboxdisplayname,...

How to Execute a PowerShell Script from SSIS

Does anyone know how to execute a PowerShell script from SSIS? I have created the script and it works from from the command line. The script takes a couple of command line parameters, which work fine when called from cmd.exe. I'm using an Execute Process Task in SSIS and cannot get the script file to execute. I'm using expressions to...

PowerShell: Performance of .NET methods calls

Is it possible to call a .NET method from PowerShell with early binding? I have a pipeline script which calls a single .NET method in process {...}. PowerShell calls this method via reflection, and right now Invoke (not the method itself, just reflection call) takes 70% of total execution time. The method is always the same, so I would...

invoke __dopostback inside IE via powershell

Hey. I'm writing powershell script that simulates actions performed by user on the page. I have a problem with performing click on a button. Page has form and inside button that saves changes to database: input type="button" onClick="__doPostBack('someIdentifier','SAVE')" value="Save changes" I need to invoke that from the client si...

Powershell and Automation

I am just having a look at using Powershell, along with VI-Toolkit, to produce reports and charts showing VMware ESX performance and resource usage. So far, so good. But I am having trouble with doing the automation of chart objects (using OWC11.ChartSpace). As an example, I want to be able to control the x and y axes in terms of maximum...

How to control processes in a Hyper-V VM's console?

I want to script the building of a Hyper-V VM as part of a build process. Specifically I need to be able to launch processes, perhaps sending keys into the VM as well, but as long as I can launch processes with specific command-lines I think I'll be good. I'm already aware of this useful library: http://www.codeplex.com/PSHyperv, but i...