powershell

Subsonic Access To App.Config Connection Strings From Referenced DLL in Powershell Script

I've got a DLL that contains Subsonic-generated and augmented code to access a data model. Actually, it is a merged DLL of that original assembly, Subsonic itself and a few other referenced DLL's into a single assembly, called "PowershellDataAccess.dll. However, it should be noted that I've also tried this referencing each assembly indiv...

How can I append the content of a.bin to b.bin in Powershell?

How can I append the content of the file a.bin to the file b.bin in Powershell? ...

Any way to specify a non-positional parameter in a powershell script?

I've got the following at the start of a script Param( [string]$command, [string]$version = "1.1.0" ) This is fine, only I need for $version to not be a positional parameter, so that if you type .\script.ps1 run argument Then $args should contain argument and $version should be 1.1.0. Is this even possible? I know I can do it wit...

Powershell 2.0 Hang When Run From MsDeploy pre- post- ops using c/

I am trying to invoke powershell during the preSync call in a MSDeploy command, but powershell does not exit the process after it has been called. The command (from command line): "tools/MSDeploy/msdeploy.exe" -verb:sync -preSync:runCommand="powershell.exe -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command C:/MyIns...

Powershell: Get-Process Returns "Invalid" VM Size

I'm running PowerShell 2.0 on Windows XP SP3 and I execute: PS> ps firefox And it returns: Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName ------- ------ ----- ----- ----- ------ -- ----------- 859 44 340972 351580 684 9,088.22 7744 firefox However, Windows Task Manager shows ...

Parameters with default value not in PsBoundParameters?

General code Consider this code: PS> function Test { param($p='default value') $PsBoundParameters } PS> Test 'some value' Key Value --- ----- p some ...

get-wmiobject sql join in powershell - trying to find physical memory vs. virtual memory of remote systems

get-wmiobject -query "Select TotalPhysicalMemory from Win32_LogicalMemoryConfiguration" -computer COMPUTERNAME >>output.csv get-wmiobject -query "Select TotalPageFileSpace from Win32_LogicalMemoryConfiguration" -computer COMPUTERNAME >>output.csv I am trying to complete this script with an output as such: Computer Physical Memo...

Powershell interact with open Excel

To interact with excel in Powershell it is common to start a new excel as follows: $x = New-Object -comobject Excel.Application Instead of that I have an open Excel process already. (I get it as follows) $excelprocess = Get-Process | Where-Object {$_.name -eq "excel"} | Sort-Object -Property "Starttime" -descending | Select-Object -F...

Powershell call web service on new email event (Exchange 2010)

I have Exchange 2010 and I need to run a process using web services against every new email to come in to a mailbox. The process will basically add the email to an internal task list. Can I use Powershell for this? Having never used Powershell before I don't really have a clue on it's capabilities. If not can anyone suggest another w...

Drag and Drop to a Powershell script

I thought I had an answer to this, but the more I play with it, the more I see it as a design flaw of Powershell. I would like to drag and drop (or use the Send-To mechanism) to pass multiple files and/or folders as a array to a Powershell script. Test Script #Test.ps1 param ( [string[]] $Paths, [string] $ExampleParameter ) "Paths" $P...

Speed Up PowerShell Scripts in V2?

Hi, I'm running a number of scripts using PowerShell V2, and I have noticed a long pause when the console window first loads. What can I do to improve the performance of my scripts? Thanks, MagicAndi ...

Try method in powershell

So I want to build a try method into my powershell script below. If I am denied access to a server, I want it to skip that server. Please help.. [code]$Computers = "server1", "server2" Get-WmiObject Win32_LogicalMemoryConfiguration -Computer $Computers | Select-Object ` @{n='Server';e={ $_.__SERVER }}, ` @{n='Physical Memory';e={ "$('{...

How do I use SMO in PowerShell to script slightly altered objects?

I'm trying to generate scripts from a database, but with slight modifications to those objects. For example, I want to generate the script for a stored procedure, but I want the script to create it under a different schema. I have an example of what I'm currently trying below. If I'm going in a completely wrong direction then please poi...

Powershell - convert log file to CSV

I have log files that look like this... 2009-12-18T08:25:22.983Z 1 174 dns:0-apr-credit-cards-uk.pedez.co.uk P http://0-apr-credit-cards-uk.pedez.co.uk/ text/dns #170 20091218082522021+89 sha1:AIDBQOKOYI7OPLVSWEBTIAFVV7SRMLMF - - 2009-12-18T08:25:22.984Z 1 5 dns:0-60racing.co.uk P http://0-60racing.co.uk/ text/...

Powershell Remoting: using imported module cmdlets in a remote pssession

Is there a way to use modules that were imported in a local session in a remote session? I looked at import-pssession, but I don't know how to get the local session. Here's a sample of what I want to do. import-module .\MyModule\MyModule.ps1 $session = new-pssession -computerName RemoteComputer invoke-command -session $session -scriptbl...

PowerShell script to restart a service

My mission is to press a keyboard sequence, such as Ctrl +Shift +R, to restart a Windows Service. I have a script which works fine in the PowerShell ISE, when launched with administrative privileges. When I try with a PowerShell script it fails due to insufficient Administrative Privileges. It’s galling that I can get it to work with ...

when executing Powershell Script from Ruby "Can't convert true into String" error

I am trying to execute a powershell script from Ruby, I have entered the below command: scriptPath = system('powershell \"C:\\Scripts\\DB_Setup.ps1\"') The ruby Script is handling exceptions when an error is raised to stop the script as below command: rescue => ex message = "\nscript on server '#{`hostname`.strip()}' terminated u...

powershell.exe tab completion - list alternatives?

I've never really used PowerShell before, and playing with it a bit, it looks like it uses cmd.exe's style of tab completion (fill in the first likely candidate, and then you can use tab to cycle through other alternatives). I'd much prefer the way e.g. bash works, where if there are multiple candidates, it shows a list of them. Is ther...

What data formats does PowerShell most easily read ?

I'm trying to use PowerShell with SharePoint. I'd like my PowerShell scripts to load my SharePoint farm configuration from files rather than either hard coding the configuration in the scripts, or having to pass in the same parameters each time. This the kind of information I need to store. WebFrontEnds: Web1, Web2, Web3 CentralAdmin:...

Which tool / technology: System management for databases and dependent services

A follow-up on this system management question: Since I probably will not get much feedback on serverfault I'll give it a try here. My main concern is to reflect the dependencies between the databases, services ans tasks/jobs I'll have to manage. Besides considering Powershell, I even thought about using MSBuild because it would allow...