powershell

Powershell equivalent of bash ampersand (&) for forking/running background processes

In bash the ampersand (&) can be used to run a command in the background and return interactive control to the user before the command has finished running. Is there an equivalent method of doing this in Powershell? Example of usage in bash: sleep 30 & ...

What's a good way in PowerShell to check for an IP address switch on a webserver?

Problem Our web host provider is changing the IP address of one of the servers we are on. We have been given a time frame for when the switch will take place, but no exact details. Therefore, our current poor man's check requires a periodic page refresh on a browser to see if our website is still there. Question We are all programmers...

How to get list of running applications using PowerShell or VBScript

I need to programmatically get a list of running applications as shown in the "Applications" tab inside the Windows Task Manager using PowerShell or VBScript. All I could find so far is how to list processes using VBScript and WMI. ...

How can I determine for which platform an executable is compiled?

I have a need to work with Windows executables which are made for x86, x64, and IA64. I'd like to programmatically figure out the platform by examining the files themselves. My target language is PowerShell but a C# example will do. Failing either of those, if you know the logic required that would be great. ...

How do I recycle an IIS AppPool with Powershell?

I haven't really done any Windows scripting at all, so I am at a loss on how to pull this one off. Anyway, basically what we want to do is have a script that will take an argument on which IIS AppPool to recycle. I have done some research on Google and haven't had much success on getting things to work. Here is what I am trying now: ...

Windows Powershell & visual studio '08 paths

I'm trying to configure Windows Powershell to work with Visual Studio. Nothing fancy, just get things set so I can cl & nmake. I think all I need to do is edit the path setting(but I don't know how to set that in WPSH). ...

Does Windows Powershell have a Try/Catch or other error handling mechanism?

In a script, when a command-let or other executable statement errors out, is there a try/catch type of mechanism to recover from these errors? I haven't run across one in the documentation. ...

Embedding Powershell CTP 2 in C#

I have an application that has Powershell 1 embedded into it, but we need to be able to use Powershell STAThreaded which is available in Powershell 2 CTP. Currently, System.Management.Automation is at 1.0.0.0. Does anyone know how to get Visual Studio to use the newer dll? ...

Can I transform object properties during output with Select-Object/Export-CSV?

I'm using the Quest AD cmdlets, particularly Get-QADUser, to pull a list of users from AD and return just a few attributes. No problems, easy enough, but I want to transform one of the properties (parentContainerDN) before exporting to CSV. Get-QADUser -name "Froosh" | Select-Object logonName,homeDrive,parentContainerDN | Export-CSV C:...

Command/Powershell script to reset a network adapter

OS: Vista enterprise When i switch between my home and office network, i always face issues with getting connected to the network. Almost always I have to use the diagnostic service in 'Network and sharing center' and the problem gets solved when i use the reset network adapter option. This takes a lot of time (3-4 min) and so i was tr...

Powershell - Increase the timeout for retrieving XML from a URL

I'm trying to retrieve an XML stream from a URL. For most URLs my code below works fine. But, I have a couple URLs that timeout. The URLs in question do work from Internet Explorer. $webclient=New-Object "System.Net.WebClient" [xml]$data=$webclient.DownloadString($url) So, I went searching for a way to increase the timeout period. Fro...

call OpenFileDialog from powershell

When I run the following, PowerShell hangs waiting for the dialog to close, even though the dialog is never displayed: [void] [Reflection.Assembly]::LoadWithPartialName( 'System.Windows.Forms' ) $d = New-Object Windows.Forms.OpenFileDialog $d.ShowDialog( ) Calling ShowDialog on a Windows.Forms.Form works fine. I also tried creating a ...

call FolderBrowserDialog from powershell

Similar to this question, after running the following code the browser dialog does appear with all the correct buttons, but the selection area that usally displays available folders is missing: [void] [Reflection.Assembly]::LoadWithPartialName( 'System.Windows.Forms' ) $d = New-Object Windows.Forms.FolderBrowserDialog $d.ShowDialog( ) ...

PowerShell array initialization

What's the best way to initialize an array in Powershell? For example the code $array = @() for($i=0; $i -lt 5;$i++) { $array[$i] = $FALSE } generates the error Array assignment failed because index '0' was out of range. At H:\Software\PowerShell\TestArray.ps1:4 char:10 + $array[$ <<<< i] = $FALSE ...

Does powershell have an equivalent to popen?

I need to be able to launch a process and read the output into a variable. Then based on the return of the command I can choose to show the full output or just a selected subset. So to be clear, I want to launch a text based process (psexec actually) and read the output from that command (stdout, stderr, etc) into a variable rather tha...

Substitute member of variable within string in Powershell

I have the following string expression in a PowerShell script: "select count(*) cnt from ${schema}.${table} where ${col.column_name} is null" The schema and table resolve to the values of $schema and $table, respectively. However, an empty string is supplied for ${col.column_name}. How can I dot into the member of a variable as part o...

Send administrative commands to my C# Windows Service using own PowerShell CmdLets

Hi, I have a C# Windows application which runs a service. I would like to leverage PowerShell in order to offer a command line management interface for administering my running service. From my point of view, I am trying to offer the same administrative interface a la Exchange 2007. Do you have any suggestion or sample code on how to ...

Access DB5 to MySQL automatically

Hello I have a problem, and was hoping I could rely on some of the experience here for advice and a push in the right direction. I have an MS Access file made by propietary software. I only want to take half the columns from this table, and import into new(not yet setup)mysql database. I have no idea how to do this or what the best way...

What do you use to develop for PowerShell?

I don't see a Visual Studio plugin for it (although I didn't look that hard, so I might have missed it), and searches turn up random third-party solutions, but is there something that comes with PowerShell or something that plugs into Visual Studio? ...

using system.thread.threadpool in powershell

Hi all, I am after a example of some code in powershell using the threadpool. my friends at google can not help me. Any example would be great. Donald ...