cmdlets

Using Remove-Item with Credentials

I am attempting to use the Remove-Item cmdlet as part of an automation for a system. The files are stored on a server that requires elevated rights to perform the file deletion. I have access to a domain admin account that I use for such automation scripts. The code below will build the PSCredential object: $password = New-Object Sys...

Help with Windows PowerShell

I'm trying to access a method of text file, I use this first: Get-Item file.txt | get-member Then I would like to use the GetType() method, but it says it doesn't recognize file.txt as the name of a cmdlet,function,script file or operable problem. I need to access that or any other method :D ...

Use PowerShell to stop-process, can i bypass confirm?

Hi All, I'm a powershell newbie, but I often find myself starting and stopping a small group of services when I'm debugging some code. In Powershell I can easily stop the processes using a wildcard but it makes me confirm. There is a -confirm parameter, but I must not be using it correctly? `Stop-Process -ProcessName alcore.* -Confirm` ...

Powershell help, if process exists, stop it, else start a service??

Hi All, I'm pretty new to Powershell. I have 2 different scripts I'm running that I would like to combine into one script. Script 1 has 1 line Stop-Process -ProcessName alcore.* -force It's purpose is to end any process that begines with "alcore." Script 2 has 1 line as well Start-Service -displayname crk* It starts any service ...

Problems debugging a PowerShell cmdlet

I'm using Visual Studio 2010 on Windows 7 64-bit Professional. I'm having trouble debugging a custom PowerShell cmdlet. Configuration Language: C#, targeting .NET Framework 3.5 SP1. Platform target: Any CPU Start Action: C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe Command line arguments: -noexit -command Add-PSSnapIn MyC...

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". ...

Calling function from Powershell Cmdlet

I'm trying to create a cmdlet that calls Powershell function. Can this be done? Idea is to have static cmdlet that enumerates a set of data and then calls defined function to do something for each item. I can always copy - paste a base template for the enumaration part, but it really easy to make errors while making modification to para...