powershell

Powershell colored directory listing is incorrect with format-wide

I got this colored dir script from http://tasteofpowershell.blogspot.com/2009/02/get-childitem-dir-results-color-coded.html: function ls { $regex_opts = ([System.Text.RegularExpressions.RegexOptions]::IgnoreCase -bor [System.Text.RegularExpressions.RegexOptions]::Compiled) $fore = $Host.UI.RawUI.ForegroundColor $compressed = New...

Is Powershell a mature enough tech for enterprise to be using?

Is Powershell a mature enough tech for enterprise to be using? Are its many benefits worth the time and effort to convert existing VBS scripts, or would you only use it for new scripting projects? We are currently using a mixture of vbs and batch files, with a login script as opposed to alot of GPO. We don't have a huge number of .NET p...

Looping through controls in WPF / Powershell

I am trying to loop through some controls in a Powershell / WPF application. Nothing fancy, just setting some text on a mouseEnter event. It works fine if I don't loop the code: $reader = New-Object System.Xml.XmlNodeReader $xaml $d = [Windows.Markup.XamlReader]::Load($reader) $d.FindName("GridOne").add_mouseEnter({ $d.Find...

Using Win32::API to accessing the methods of a DLL in Perl

I have in my possession a Microsoft Powershell script which examines all the files in a folded ending in .wtv (Windows Media Center recorded TV programmes), extracts some metadata (using a DLL called "Toub.MediaCenter.Dvrms.dll") and then writes it to stdout: [void][System.Reflection.Assembly]::LoadFile("C:\Toub.MediaCenter.Dvrms.dll") ...

Hudson won't run any Powershell scripts using Powershell plugin

Hi Folks, Encountered a problem executing Powershell scripts from Hudson CI server using the Powershell Plugin. I'm running: Hudson v1.362 Windows 2003 Powershell 1.0 I am trying to use the Powershell plugin for Hudson. Anything I try just gives me: File C:\DOCUME~1\SVC_PR~1\LOCALS~1\Temp\hudson2144883754471568213.ps1 cannot ...

Copying an SMO collection into an array in Powershell

I've written a Powershell script which will compare two databases and come up with a list of objects in one of the databases to remove. I put those items (as a customized object with a name and schema) into an array. In the next step of my script I iterate through the objects in the database and see if they match an object in my array. ...

Powershell script to locate specific file/file name?

Searched everywhere for this but no luck. I wanted to write a small script that searched for an exact file name, not just a string within a file name. For instance if I search for 'hosts' using Explorer, I get multiple results by default. With the script I want ONLY the name I specify. I'm assuming that it's possible? I had only really...

Calling web services from powershell: "Server did not recognize the value of HTTP Header SOAPAction"

I am attempting to call a web service from a powershell script. I am not the author of the web service, nor do I know much about web services. (I'm only ramping up in PowerShell, as well.) The vendor of the web software has provided me with a .wsdl file. I ran wsdl.exe against it, then csc.exe against the .cs file that was generated, i...

Using Powershell to automating a bat file that ends with PAUSE

I have a batch file that I can't change, but I want to automate with Powershell 2.0. It ends with a PAUSE command, which displays: Press any key to continue... Is there an way to call this batch file from a powershell script, but have it exit without needing a user to press something? ...

how to edit a file in powershell remoting session (powershell)

I am connecting to another computer using powershell remoting, really nice. can do lots, but how do I edit a file? PS C:\Users\guutlee> Enter-PSSession -ComputerName appprod [appprod]: PS C:\Users\guutlee\Documents> cd \myapp [appprod]: PS C:\myapp> what can I do to open a file editor on a file on the remote machine? ...

What is your best PowerShell hyper-productivity script?

I'm getting into PowerShell scripting and am impressed by its muscle, flexibility and grit, especially compared to Microsoft`s classic DOS command line implementations. Basically I want the community to gain quick wins from your experience with it. What is your best PowerShell hyper-productivity script? Rules of engagement for the scrip...

Powershell module loading stops in C# code when Write-Progress is used

I have this service that, when request is received, runs a powershell command and returns result. Here is the invoker class code: public class PowerShellScript { public PowerShellScript() { } public Object[] Invoke( String strScriptName, NameValueCollection nvcParams ) { Boolean bResult = true; int n = 0; ...

How can I capture if a dialog box is on screen in Powershell?

I am writing a script to automate an installation package. Annoyingly, there is no "silent" installation mode. (Actually it's "half silent" - it runs in the background and then pops up with a dialog box telling the user to reboot.) I want to automate this, by detecting the dialog box has appeared and then either terminating the process ...

is there a way to move folder to trash using cmd.exe or powershell?

is there a way to move a folder to trash using cmd.exe? (Windows Vista) (that is, the behavior should be identical to user moved the folder to trash from GUI) is there a way to do it using PowerShell? ...

how to get line number with error inside trap in powershell?

I use trap to write erors to file, and want write line number where error ocured. $_.Exception.StackTrace is not answer. Where I can get line number of error? Maybe some predefined variable? ...

Creating BizTalk 2006 adapters programmatically

I'm writing a configuration script for a BizTalk server I need to create a few adapters. In the "BizTalk Server Administration" application this is done by going to Biztalk Server Group / Platform Settings / Adapters and choosing New / Adapter from the right-click menu. I'd like to automate this process somehow, using a Powershell sc...

How do I export IIS7 site and app pool settings using Powershell and the Web Administration Provider?

I would like to export the site settings and app pool settings for a specific site in IIS7 using Powershell so i can restore them on another server. Anyone knows how to do this? ...

How to check if a button is clicked?

I have a following LOC in my ps1 script which displays a message with an OK button. [Windows.Forms.MessageBox]::Show($Message, $Title, [Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Information, [System.Windows.Forms.MessageBoxDefaultButton]::Button1, [System.Windows.Forms.MessageBoxOptions]::DefaultDeskto...

Add user to SharePoint 2010 group using powershell

We need to add several users to several SharePoint Groups. Does anyone have an example of how to add a user to a sharepoint group using power shell. ...

HELP! Site Column Page Not Accesible

I accidently created a field type called "Test" instead of Text using the following Powershell command: Get site and web object $site = Get-SPSite -Identity "http://mysite/sites/.." $web = $site.RootWeb Assign fieldXML variable with XML string for site column $fieldXML = ' Poweshell threw the following error: Exception calling "Ad...