powershell

Powershell in SSIS

What would I need to do in order to run a PowerShell script in an SSIS package? Does PowerShell need to be installed on the SQL server? How do I actually call the script in SSIS? Thanks ...

How do I invoke a Java process from Windows Powershell?

I am having trouble running a Java program with Windows Powershell 2.0. Any help on this would be greatly appreciated. I want the string "Hello World!" to print to the main Powershell console window. Instead, its getting printed to a separate process window that opens then suddenly closes. I don't know exactly how to tell the p...

Powershell function returning instantiated object...kind of?

I'm rather new to Powershell and am working on setting up my profile.ps1 file. I have a few managed DLLs that I use often to maintain processes throughout the day which I'd like to be able to load up with quick function calls. So I created this function in my ps1 file: function LoadSomeDll { [System.Reflect.Assembly]::LoadFrom("c:...

How can you list all SQL Server tables, their columns, and column data types using Powershell?

I'm trying to do documentation on an SQL server 2008 database. This includes listing all tables, their columns, and the column types. I've been so far as to use "get-childitem | get-member" while browsing the table, the column, and the column's extended properties, and none of them return the data type of the columns. Is there a way to l...

PowerShell search script that ignores binary files

I am really used to doing grep -iIr on the Unix shell but I haven't been able to get a PowerShell equivalent yet. Basically, the above command searches the target folders recursively and ignores binary files because of the "-I" option. This option is also equivalent to the --binary-files=without-match option, which says "treat binary f...

Equivalent of 'More' command in Powershell?

Is there a way to paginate the output by piping it to some 'more' command, which is available in linux\unix shells? ...

How to print the contents of all revisions of a particular file in Mercurial?

Let's say I have 5 revisions of a README file. How do I view them all in Mercurial? It would be nice to be able to limit the output, similar to: hg log -l 10 I'm using PowerShell, so combined solutions are also welcome. ...

Powershell Script fails after accessing Array.Length Property

Can someone explain why this script throws an exception? $byteArray = @(1,2,3) write-Output ( "{0:X}{1:X}{2:X}" -f $byteArray ) write-Output ( $byteArray.Length -ge 3 ) write-Output ( "{0:X}{1:X}{2:X}" -f $byteArray ) Basically, I am creating an array of numbers, formatting the array and then checking its length and formatting it agai...

Can I run PowerShell scripts in an Silverlight application?

Can I run PowerShell scripts in an Silverlight application? ...

Do PowerShell scripts run under Mono?

Do PowerShell scripts run under Mono? I would like to run them on a Mac. ...

C# Piping commands into PowerShell

Hi all, I need to run two powershell commands one after the other, should I create a pipeline twice or is there a better option? Thanks Runspace myRunSpace = RunspaceFactory.CreateRunspace(rc); myRunSpace.Open(); Pipeline pipeLine = myRunSpace.CreatePipeline(); using (pipeLine) { ...

Analyse Windows event log entries using PowerShell and regular expressions

I'm currently working on a PowerShell script to analyse VPN traffic by reading the event log of our VPN server. I'm using WMI to retrieve the relevant event entries and a regular expression to extract information like user name, traffic etc. The event message obviously does contain line breaks which I don't seem to be able to match via ...

Is there a function pointer or array of functions in PowerShell?

I would like to do something like this. Index into an array of functions and apply the appropriate function for the desired loop index. for ($i = 0; $i -lt 9; $i++) { $Fields[$i] = $Fields[$i] | $($FunctionTable[$i]) } #F1..F9 are defined functions or rather filter functions $FunctionTable = {F1}, {F2}, ...

Run bash script from Windows PowerShell

In cygwin, I could just do ./script.sh args, but this opens the script file in notepad in PowerShell. What do I need to do have it execute? ...

How to pass a parameter from Batch file to a function inside a Powershell script

I have a Batch file which will call a Powershell Script : BATCH FILE : @ECHO OFF powershell ..\PowerShellScript.ps1 The powershell script in turn has a function which expects a parameter : POWERSHELL SCRIPT: function PSFunction([string]$Parameter1) { Write-Host $Parameter1 } Lets say i have a value : VALUE1 which needs to ...

How can I convert a complex binary Perl regular expression to C# or PowerShell?

Hello, This Perl binary regex found at http://www.w3.org/International/questions/qa-forms-utf-8.en.php matches UTF-8 documents without the UTF-8 BOM header: $field =~ m/\A( [\x09\x0A\x0D\x20-\x7E] # ASCII | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs ...

Can I decorate advanced PowerShell functions with my own custom attributes?

For example: function TestThis() { [MySpecialCustomAttribute] [CmdletBinding()] Param(...) Process{...} } ...

PowerShell scripts every developer should know

Hi, Windows PowerShell is out a quite long time now. In comparison to the the good old windows shell it's much more powerful. Are there any scripts you use to speed up and simplify your every day work as an developer? If you can do magic with PowerShell -> please share it with us! Update Not really a script, but also very useful are Po...

Powershell acting different for values vs. arrays?

I'm trying to grab out some information from Active Directory using Powershell, but I get some strange behavior. Here's my script: $toFind = ( 'bobjones', 'samsmith' ) filter Get-AdUser { $strFilter = "(&(objectCategory=User)(sAMAccountName=$_))" $objDomain = New-Object System.DirectoryServices.DirectoryEntry $objSearcher ...

Powershell script running more slowly in a runspace than in the shell

I've a PS script which I use to keep track of my VMWare ESX servers. I need to run it as a service so that I'm not permanently logged on. Unfortunately, the script runs more slowly if I use a runspace inside a service rather than just running the script through the powershell console. It's taking 2-5 minutes to make calls to the VMWare w...