powershell

how to use powershell to remove space from end of line in text file

I found find and replace text answer from another question and hope that someone have the answer to my question. how to use powershell to remove extra spaces at end of line in a text file? Thanks in advance Swanl ...

How to make a created virtual directory in IIS6.0 as application using powershellv2.0

HI i created some virtual directories in my iis using following code Function InputBox ($message, $title, $default) { [void][reflection.assembly]::loadwithpartialname("microsoft.visualbasic") $result = [microsoft.visualbasic.interaction]::InputBox($message,$title, $default) return $result } $server=inputbox("enter the name...

Finding BizTalk 2006 installation folder

Is there any way to find out where Biztalk is installed on a machine using a PowerShell script? ...

What is the command to access Exchange Management Tools from C# code in Exchange 2010

In Exchange 2007 this line of code is used to load the Exchange Poweshell commands snapin: PSSnapInInfo info = rsConfig.AddPSSnapIn( "Microsoft.Exchange.Management.PowerShell.Admin", out snapInException); However, this does not exist in Exchange 2010 and I am pulling my hair out trying to find out how to access the Exchange Powers...

Is it possible to handle switch parameters with Add-Member methods?

When adding a method to a PSObject using Add-Member is it possible to use [switch] parameters? If so how does the syntax work when calling these methods? ...

In Powershell, add tab completion for git branches

when inside a git repository, is it possible to add tab completion for git branches to Powershell? ie: PS> git checkout ma<tab> would result in PS> git checkout master ...

Working with dates in PowerShell

I am trying to use the Get-Date cmdlet to get yesterdays date. I have found the .AddDay(-1) command and that seems to work. The next thing i need to do is extract the date in YYMMDD format. This is that part i can not figure out how to do. This is what i used to get todays date and the previous day. $a = Get-Date "Day: " + $a.Day "M...

Executing files via Powershell

Hi, I want to write a powershell script to execute all the files in a directory, by alphabetical order. Problem is, I also want to execute each file in the directory. How can I do this last bit? Thanks ...

Executing a Command stored in a Variable from Powershell

I have a command that i have build and stored in a variable in power shell. This command works if i do a write-host and copy and past into a standard cmd.exe window. How do i execute this command from inside my script? I have tried several combination of invoke-command or invoke-expression with no luck. This is how i built the varia...

Using custom cmdlet from SQL Server

I want to execute a Powershell script from SQL Server's maintenance plan. This is fine and perfectly possible, but what if I want to use a custom cmdlet? Can this still work from the Powershell script SQL Server job step (in this case, I need to use the SCVMM cmdlet). ...

Powershell Hotkey to Erase Current Line?

I would like to execute a hotkey that would erase the current line in the powershell session. Is such a thing possible? ...

Having trouble running this C# code on XP

I'm writing an application that can run PowerShell scripts which I'd like to be run on the application's thread. The following code: Runspace runspace = RunspaceFactory.CreateRunspace(); // create Powershell runspace runspace.ThreadOptions = PSThreadOptions.UseCurrentThread; Works and compiles fine on Windows 7, but can't be compiled...

Powershell Interaction with Access 2007, how to Save Report as PDF?

I have an access database and a report in that database. I am using the access.application comobject to gain access to access, i.e. $db = New-Object -ComObject Access.Application $db.OpenCurrentDatabase("foo.accdb") This works fine. However, as suggested in another similar question I am unable to get the report out of the db by usin...

Are there any console (not GUI!) alternatives to powershell.exe?

There are a number of GUI hosts for Powershell (Powershell ISE, PoshConsole, etc) but I'm not aware of any purely console hosts other than powershell.exe. Are there any that offer any advantages over powershell.exe? I'd like to be able to customise more of the host behaviour - specifically to add and customise key bindings other than TA...

Iconv is converting to UTF-16 instead of UTF-8 when invoked from powershell

I have a problem while trying to batch convert the encoding of some files from ISO-8859-1 to UTF-8 using iconv in a powershell script. I have this bat file, that works ok: for %%f in (*.txt) do ( echo %%f C:\"Program Files"\GnuWin32\bin\iconv.exe -f iso-8859-1 -t utf-8 %%f > %%f.UTF_8_MSDOS ) I need to convert all files on the d...

Creating & Editing performance counters in a powershell script or command line

Hello, I'm trying to move the verification & creation of my performance counter groups, and the counters themselves, out of my web service and into a powershell script that's run during deployment. Can this be done? Or am I stuck using a simple app to build the groups & counters? Thanks much :) ...

Extract a Table from an HTML File with PowerShell or VBS

I have a two part problem that needs fixing. I'll try my best to describe it then break down what I "think" the steps are. I am trying to get a specific table in a webpage and email it to myself. At the moment what I am trying is to use GNU\Win32 wget.exe (I'd rather use PowerShell natively but for some reason I couldn't, perhaps becau...

how to iterate over files with powershell?

I want to iterate over files in a folder using powershell script; ...

Powershell vs UNIX

Greetings, I would like to know if there is any equivalent Powershell commands for the following UNIX commands: make trap Thanks. ...

Creating PerformanceCounterCategory in Powershell

Hello, I'm trying to run the following script in powershell: $counters = @() $counters = $counters + [Diagnostics.CounterCreationData]::("Hit counter", "Number of total hits", [Diagnostics.PerformanceCounterType]::NumberOfItem32); $counters = $counters + [Diagnostics.CounterCreationData]::("Hits per second", "Number of average hits pe...