powershell

how to map a drive with powershell

How on PowerShell do I map a network drive with user name & password? I am trying to do an equivalent of command prompt (cmd.exe) command: net use G: \\10.10.10.1\f$ /USER:prod\joe myStrongPasswordHere I found on this site solution below, but I get an error below. Here is command and error: $net = new-object -ComObject WScript.Netwo...

SIGHUP equivalent in powershell

I am interested in knowing if we can catch SIGINT, SIGHUP equivalent signals in Powershell and how to do it? I also could not find if there is anything equivalent in powershell like "stty -echo" in unix environment. Thanks, ...

Invoke a powershell script from IIS

The 3rd party git repository service I use provides post-commit hook where it will post the commit details in JSON to specified URL. Most of build automation is via powershell (pull from git repo, build, copy artifacts). What Id like to be able to do is somehow launch the powershell script when the specified URL is hit. Im struggling to...

When would I use PowerShell over traditional applications?

I've been hearing a lot about PowerShell recently, and was wondering whether there's any reason to use PowerShell instead of (for example) a console application or Windows service using WMI behind the scenes. What are the benefits and advantages of PowerShell? What is it for? ...

powershell script delete folders regular expression

I've written a Powershell script to delete subfolders within a given folder whose name starts with either 0 or 1. This script seems to work only for non-empty folders. I want it to delete the inner contents too. Is there any switch that makes it possible? Also, for some files, I get an error about not having enough permissions whereas th...

signing PowerShell Scripts

i am trying to sign my powershell scripts so i can execute them with no problems. I have my code signing cert created on my system and can view it from inside PowerShell. When i co to sign it i keep getting errors PS C:\xxadmin> get-childitem cert:\CurrentUser\my -codesign Directory: Microsoft.PowerShell.Security\Certificate::Curr...

How do I use Add-Type to load Microsoft.Web.Deployment

I am writing some PowerShell scripts that use msdeploy api. I can load the assembly using The location is in the GAC PS > [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Deployment") | fl Location Location : C:\Windows\assembly\GAC_MSIL\Microsoft.Web.Deployment\7.1.0.0__31bf3856ad364e35\Microsoft.Web.Deployment.dll ...

TransactionScope with IsolationLevel set to Serializable is locking all SQL SELECTs

I'm using PowerShell transactions; which create a CommittableTransaction with an IsolationLevel of Serializable. The problem is that when I am executing a Transaction in this context all SELECTs are blocked on the tables affected by the transaction on any connection besides the one executing the transaction. I can perform gets from withi...

Convert Perl MD5 Digest and Create to PowerShell

I am trying to convert the following in Perl to PowerShell, I am stuck on the MD5 Digest and Create. timestamp=1283473470 key='this-is-my-key' secret='secret' perl -e "use Digest::MD5 qw(md5 md5_hex); print md5_hex('$key' . '$secret' . $timestamp);" For testing purposes I am setting the time stamp to a static number. That way I can c...

Use custom PowerShell defined type for parameter type specification

I define a custom PowerShell type with New-Object. I would like a parameter to be of my defined type, is it possible to specify this type in a declarative way? The following code gives me the error: "Unable to find type [BuildActionContext]: make sure that the assembly containing this type is loaded." Can we specify the type declarative...

System.EnterpriseServices and Powershell Locking dll

I am trying to use System.EnterpriseServices to uninstall a c# com+ component, replace the dll and reinstall the new version. The problem is that when I get to the line copy-item the script always fails because System.EnterpriseSerivces is locking the destination file. If I break the script up into two sections one that calls Unistal...

Returning a variable value to a rake script

I'm executing a rake script that calls a powershell function. The function returns a value, how can i get this value and provide it to my rake template file? Thanks for any suggestions ...

powershell click on a hyperlink

Hi i need to click on a hyperlink in a aspx webform using powershell how can i achieve it. also that link shows a drop down menu and i have to select right option from that link. thanks ...

What is the Powershell analogue of $@ used to call another command?

In a Unix shell script, to call command 'foo' on the original arguments to the script, you just write foo $@ In Powershell, $args is an array of (typically) strings holding the current script's arguments. If you write foo $args will the same thing happen as in bash or other typical Unix shell script interpreters? ...

How can I recursively delete folder with a specific name with PowerShell?

I can delete files with specific extensions in multiple folders with this: Get-childitem * -include *.scc -recurse | remove-item But I also need to delete folders with a specific name - in particular those that subversion creates (".svn" or "_svn") when you pull down files from a subversion repo. ...

Run SharePoint Timer jobs from PowerShell

We are currently moving from using stsadm to using PowerShell for our SharePoint install scripts. We have not been able to find an equivilent to this: stsadm -o -execadmsvcjobs We have tried putting in a pause, but it varies how long the pause needs to be. Is there an equivilent command in PowerShell, or could we run this command fr...

How can I stop/start IISADMIN with powershell

I have multiple servers that need to have the IISADMIN service restarted. I need to do this remotely, so I have code that will ask for credentials. however when I get to the point of stopping it and restarting it, it fails because the dependant services. I am trying to use IISRESET /STOP, but cannot get it to function. Any suggestions ...

Question on command to look at performance counters

Hi, Does anyone if the command(s) to look at performance counters via Powershell uses COM? Thanks ...

How to invoke a Windows Scheduled task or a batch file on a server different to the IIS server

I have a asp.net web site, I would like a page on that site to be able to invoke a Windows Scheduled task or a batch file on a server different to the IIS server? Is it possible? How should I do this? ...

What cmdlets use the IHostUISupportsMultipleChoiceSelection interface to prompt for choices?

I don't remember ever being prompted for multiple selections before in PowerShell, but I've seen several examples of hosts implementing this interface. Unfortunately, those are the only references I've seen to the interface. I've never seen "here's how to test that you're implementing it correctly". ...