powershell

Extract a value from a dtsx file with Powershell

Sql Server Integration Services packages are stored as xml files with a dtsx extension. I need to be able to extract their build numbers with Powershell. The relevant part at the top of the file looks like- <?xml version="1.0"?> <DTS:Executable xmlns:DTS="www.microsoft.com/SqlServer/Dts"> <DTS:ExecutableType="MSDTS.Package.1"> <DTS:Prop...

unicode in powershell with python? alternative shells in windows?

I want a shell that supports unicode in windows, powershell as it ships doesn't seem to. Powershell V2 (win7 x64) : PS C:\> powershell Windows PowerShell Copyright (C) 2009 Microsoft Corporation. All rights reserved. PS C:\> python Python 2.6.2 (r262:71605, Apr 14 2009, 22:46:50) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copy...

How to extract rows from a log file using Windows command line tools or batch file?

I would like to extract certain rows from a log file using native Windows command line tools or batch file (.bat). Here's a sample log file: 2009-12-07 14:32:38,669 INFO Sample log 2009-12-07 14:32:43,029 INFO Sample log 2009-12-07 14:32:45,841 DEBUG Sample log 2009-12-07 14:32:45,841 DEBUG Sample log 2009-12-07 14:32:52,029 WARN Sam...

Printing unicode characters in PowerShell via a C++ program

My end goal here is to write some non-latin text output to console in Windows via a C++ program. cmd.exe gets me nowhere, so I got the latest, shiny version of PowerShell (that supports unicode). I've verified that I can type-in non-unicode characters and see non-unicode console output from windows commands (like "dir") for exampl...

Generics in PowerShell 2 not working?

How could I make a List in PowerShell 2? I've tried these: [activator]::createinstance(([type]'system.collections.generic.list`1').makegenerictype([string])) and [activator]::createinstance(([type]'system.collections.generic.list`1').makegenerictype([string])) and all I get is just nothing. What's going wrong? I'm running XP SP3,...

Retrieve Details of Deployed Solutions in SharePoint using PowerShell

Hi, I need to retrieve the details of all deployed SharePoint solutions, as are displayed in the Central Administration > Operations > Solution Management (AKA the Solution Store), using a PowerShell script (v2.0). Can anyone offer any guidance on how to retrieve this information from the SharePoint solution store via the SharePoint AP...

How to pull the filenames from an .htm file using PowerShell's select-string?

I am trying to search through the .htm files for our intranet to find out which network files are being linked to on which pages of the site. What I would like to do is have PowerShell go through each .htm and return any string that begins with "file:///" and ends with a double quote. For instance: <td colspan="3"><a href="file:///X:/...

Suspending a PowerShell script until a action is complete i.e. opening & closing Notepad

Hi, Is there a way of suspending a PowerShell script until some action has been completed. For example if I was using a Linux shell and I typed gedit then gedit would load but the shell would be suspended until I closed gedit (unless '&' was added to the end of the command). Is there anyway to mimick this behaviour with PowerShell? So ...

powershell 2 event handling

I want to handle the System.Windows.Forms.NotifyIcon's BalloonTipClicked. That is to say, I want to handle the event when the tip is clicked. My code is below, however I can't catch the event. Please help ! [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") [void] [System.Reflection.Assembly]::LoadWithParti...

Powershell advanced functions: are optional parameters supposed to get initialized?

filter CountFilter($StartAt = 0) { Write-Output ($StartAt++) } function CountFunction { [CmdletBinding()] param ( [Parameter(ValueFromPipeline=$true, Mandatory=$true)] $InputObject, [Parameter(Position=0)] $StartAt = 0 ) process { Write-Output ($StartAt++) } } $...

How do I pass common powershell command line parameters between cmdlets on the pipeline?

Say I've got two cmdlets, 'new-foo' and 'do-bar'. Both cmdlets need to authenticate to a service in order to perform their action, and 'do-bar' takes a foo. Today, I can do: new-foo -host localhost -username user -password password -whateverOtherArgs And I can do: do-bar -host localhost -username user -password password -foo myFoo ...

PowerShell manifest referencing external assembly

Is it possible to register a new PowerShell module just by defining a new module manifest and putting it in the specified directory? E.g. a a new module named SampleModule should be created. I put the empty manifest file SampleModule.psd1 in the directory <%PSModulePath%>\SampleModule. (It doesn't matter which (user or global) module pa...

How I can use PowerShell with the Visual Studio 2010 Command Prompt?

I've been using Beta 2 for awhile now and it's been driving me nuts that I have to punt to cmd.exe when running the VS2010 Command Prompt. I used to have a nice vsvars2008.ps1 script for Visual Studio 2008. Anyone have a vsvars2010.ps1 or something similar? ...

What runs in PowerShell when I type "alias"?

What runs in PowerShell when I run the "alias" command? Is it an alias? A function? It appears that "alias" is itself an alias to the get-alias command. Yet alias itself does not show up in the list returned by get-alias. Is it being stripped out? (This is out of curiosity, I'm not planning on re-aliasing "alias" or anything crazy.) ...

Confused about why PowerShell treats a function different from a childitem, even if same type

I'm confused about the difference between these two things: $env:path And function path {$env:path} path Both return strings, according to get-member. Yet -match does not work the same on both. If I use -match on $env:path, it works as I'd expect, returning true/false. But if I use -match on path (the new function) then it always ...

Better PowerShell hosts than powershell.exe?

I've been trying to switch over to PowerShell from my old favorite 4NT. It's missing a lot of niceties that 4NT has been adding over the last 20 years (I'm an old 4DOS user). For example, in 4NT if you type a few letters then hit up/down, then the history list is filtered by what you typed. Page up/down does a popup with all matches and...

powershell sending multiple parameter to a external command

I am trying to run a external exe from a powershell script. This exe wants 4 parameters. I have been trying every combo of invoke-item, invoke-command, & 'C:\program files\mycmd.exe myparam', made a shortcut in C:\ to get rid of the spaces in the path. I can make it work with one parameter, but not with more. I get various errors. To...

Methods to convert C# code to a PowerShell Script?

Hi, I regularly have to convert an existing C# code snippet/.CS file to a PowerShell script. Can anyone offer any tools or methods that would allow some automation of this? Note, while I am aware that there are methods that can convert a .cs file to a cmdlet, I'm only interested in converting the C# code to a script or module. Than...

The '<' operator is reserved for future use (PowerShell)

I am using powershell and am trying to run the following command: .\test_cfdp.exe < test.full | tee test.log test.full is a script that mimics command line inputs to test_cfdp.exe. However, I get the following error: The '<' operator is reserved for future use. Is there another way (i.e. cmdlet) I can use to get this command to wo...

Prevent ArrayList.Add() from returning the index

Hi, is there a way to supress the return value (=Index) of an ArrayList in Powershell (using System.Collections.ArrayList) or should I use another class? $myArrayList = New-Object System.Collections.ArrayList($null) $myArrayList.Add("test") Output: 0 thanks in advance Milde ...