powershell

Powershell FTPWebRequest and EnableSsl = True

I searched this site and found an FTPWebRequest example via Powershell. I put it to use and it works fine. However, when I enable SSL via EnableSsl=$True, all I get is timeouts or a delayed "227 Entering Passive Mode", which breaks the process. As soon as I disable EnableSsl, I can fly right through. Can someone point me in the right dir...

Passing a variable from Excel 2007 Custom Task Pane to Hosted PowerShell

I am testing PowerShell hosting using C#. Here is a console application that works: using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Management.Automation; using System.Management.Automation.Runspaces; using Microsoft.Office.Interop.Excel; namespace ConsoleAppl...

PowerShell update connection strings

Hi Everyone, I have the following script that will update the connection string across three different config files used in development. function Main() { pushd cd .. $aomsDir = pwd $configFiles = @( 'util\GeneratePocos.exe.config', 'src\Web.UI\web.config', 'src\Data\App.Config') $MyAOMSEntitiesConnStr = $env:AOMS_CONN_STR Write-...

Can I do this in powershell? Read the Registry, write out binary contents to file.

This is the C# code. Can you help me translate this to powershell? private static void Main(string[] args) { byte[] buffer = (byte[]) Registry.LocalMachine.OpenSubKey(@"HARDWARE\ACPI\DSDT\HP____\8510x\00010000").GetValue("00000000"); if (File.Exists("8510x.orig")) { Console.WriteLine("File 8510x.orig already exists...

Why cant I execute a commandlet with arguments from a string in powershell?

In windows powershell, I am trying to store a move command in a string and then execute it. Can someone tell me why this doesn't work? PS C:\Temp\> dir Directory: Microsoft.PowerShell.Core\FileSystem::C:\Temp Mode LastWriteTime Length Name ---- ------------- ------ ---- -a--- 8/14/2009...

A python based PowerShell ?

I just took a brief look at PowerShell (I knew it as Monad shell). My ignorant eyes see it more or less like a hybrid between regular bash and python. I would consider such integration between the two environments very cool on linux and osx, so I was wondering if it already exists (ipython is not really the same), and if not, why ? ...

How can I display my current git branch name in my PowerShell prompt?

Basically I'm after this but for PowerShell instead of bash. I use git on windows through PowerShell. If possible, I'd like my current branch name to displayed as part of the command prompt. ...

I need to rotate an image

I need to rotate an image that is passed to a function as an array of BitmapFrames. the finished product needs to be saved as a BitmapFrame as well so I can send it to my Export-Image function. Help? [Cmdlet(VerbsData.ConvertTo, "Rotate")] public class RotateCmdlet : PSCmdlet { private BitmapFrame[] bFrame, outFrame; private Bit...

How to pass command-line arguments to a PowerShell ps1 file

For years, I have used the cmd/dos/windows shell and passed command-line arguments to batch files. E.g., I have a file, "zuzu.bat" and in it, I access %1, %2, etc. Now, I want to do the same when I call a PowerShell script when I am in a Cmd.exe shell. I have a script "xuxu.ps1" (and I've added PS1 to my PATHEXT variable and associated P...

Ideas on building in automation in an application

I am working on a .NET internal test tool at the moment. The tool is GUI based at the moment. One of the things I want the tool to be able to do is to run in command line mode. This way we can run it in an automated fashion and have it crunch on some data every day. We started to put in a Command line mode in it but I am just not happy...

How do I get around PowerShell not binding pipeline parameters until after BeginProcessing is called?

I'm writing a Cmdlet that can be called in the middle of a pipeline. With this Cmdlet, there are parameters that have the ValueFromPipelineByPropertyName attribute defined so that the Cmdlet can use parameters with the same names that are defined earlier in the pipeline. The paradox that I've run into is in the overridden BeginProcessin...

Passing around command line $args in powershell , from function to function

Hi, This is a nasty issue I am facing. Wont be surprised if it has a simple solution, just that its eluding me. I have 2 batch files which I have to convert to powershell scripts. file1.bat --------- echo %1 echo %2 echo %3 file2.bat %* file2.bat -------- echo %1 echo %2 echo %3 On command line, I invoke this as C:> file1.bat ...

How to create a Hardlink using the New-Hardlink PowerShell PSCX command

I want to create a new Hardlink with the PowerShell Community Extensions PSCX commandlet New-Hardlink http://pscx.codeplex.com/. I have read the man file and tried almost every combination of commands but it won't work. What am I missing? (I know about fsutil, but I want to use this commandlet/alias) Here is the directory structure: E:...

Is there no TFS Snapin for PowerShell on x64?

I am trying to use the TFSSnapin in PowerShell from C# code using System.Management.Automation from the PowerShell SDK, however I would like to compile it using "AnyCPU". When I try debugging it in any CPU I get the "No Plugins Registered" error, I try debugging it in x86 mode and it works just fine. Is there anyway to get the Plugins re...

Adding group to group using the PowerShell ADSI provider

I tried the following after creating the new group: $adminGroup = [ADSI]"WinNT://./Administrators" $group =[ADSI]"WinNT://./Test1" #$adminGroup.Add($group) - This does not work Any idea what is missing? ...

Automated MSMQ Setup with Powershell

I am in the process of configuring a new test server for an application I support. It uses around 35 different MSMQ queues and creating these manually is obviously not loads of fun. Especially since the production version of the application is also moving servers so I'll get to do this all over again. What I'm looking for is an automated...

Execute PowerShell as an administrator from C#

I have the following C# code using (RunspaceInvoke invoker = new RunspaceInvoke()) { invoker.Invoke("Set-ExecutionPolicy Unrestricted"); // ... } which gives me the exception Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' is denied. According to this, the sol...

Powershell 2.0 Param Keyword Error

I am running Windows 7 RTM. Powershell 2.0 is installed by default. I am using the excellent Windows Powershell ISE to edit my scripts. I have the following script: Param($p) Param($d) echo $p $d I save the script as SayItAgain.ps1. When I try to run this script from the interactive shell like so: ./SayItAgain -p "Hello" I reci...

Use PowerShell to enumerate Linux SMB shares

I can list my own computer's shares no problem with: gwmi Win32_Share But when I try gwmi Win32_Share -computer myserver Where myserver is an HP MediaVault mv2120 running BusyBox. I get back the response: Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) Is there any way to get this done? ...

Update configSource of XML element in web.config using Powershell by passing in Parameters

I am trying to figure out a way to update my web.config for different environments by updating the configSource for the appSettings element in the web.config. Here are the way I know how to do it. $xml.get_DocumentElement().appSettings.configSource = $replaced_test The problem is that I want one base script where I can pass in dif...