I'm trying to run some funtions in the background of a PoSh script. The job never completes, but works fine when called normall. I've narrowed the problem down to the following line:
This line works fine:
$ws = New-WebServiceProxy "http://host/Service?wsdl" -UseDefaultCredential
but this line blocks forever
start-job { New-WebServi...
$from = "\\something\1 XLS\2010_04_22\*"
$to = "c:\out\1 XLS\2010_04_22\"
copy-item $from $to -Recurse
This works if c:\out\1 XLS\2010_04_22\ does exist . Is it possible with a single command to create "c:\out\1 XLS\2010_04_22\" if it doesn't exist.
...
It seems the System.Management.Automation assembly only ever exists in version 1.0.0.0 on my system, available in the GAC as well as in the following folder:
%ProgramFiles%\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0
I can confirm that I do have PowerShell 2.0 installed, though, since I have support for PowerShell modules an...
Hi
Frequenlty my work involves to VNC to a remote system and work on it. SInce i run command line apps on this remote system most of the time, i was wondering if there's an alternative software to command prompt which i could install on my local machine. Using this i should be able to create a session with the remote system and from the...
I'd like to clean up some directories after my script runs by deleting certain folders and files from the current directory if they exist. Originally, I structured the script like this:
if (Test-Path Folder1) {
Remove-Item -r Folder1
}
if (Test-Path Folder2) {
Remove-Item -r Folder2
}
if (Test-Path File1) {
Remove-Item File1
}
N...
I'm trying to change the color of write-host output based on the lastrunoutcome property of SQL Server jobs in Powershell....as in...if a job was successfull, the output of lastrunoutcome is "Success" in green....if failed, then "Failed" in red. I have the script working to get the desired job status...I just don't know how to change th...
Here's my situation. I have a PowerShell module which imports the PowerShell-JSON library; this library converts JSON strings into PowerShell objects. My module provides an interface to CouchDB, so my JSON strings are obtained from HTTP calls. I have a function, Send-CouchDbRequest, which makes the HTTP request to CouchDB and returns ...
I can see the 6 or so native PSSnapins, thanks to get-PSSnapin
I have added the useful QAD snapins, thanks to add-PSSnapin
My question is could you recommend any other useful third-party Snapins for PowerShell?
...
During investigation of some problem I found that the reason was unexpected different conversion to string[] of seemingly same input data. Namely, in the code below two commands both return the same two items File1.txt and File2.txt. But conversion to string[] gives different results, see the comments.
Any ideas why is it? This might be...
I am successfully using Powershell with SMO to backup most databases. However, I have several large databases in which I receive a "timeout" error "System.Data.SqlClient.SqlException: Timeout expired". The timout consistently occurs at 10 minutes. I have tried setting ConnectionContext.StatementTimeout to 0, 6000, and to [System.Int32]::...
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 ...
General code
Consider this code:
PS> function Test { param($p='default value') $PsBoundParameters }
PS> Test 'some value'
Key Value
--- -----
p some ...
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
...
Good morning,
I have a two Powershell scripts; main.ps1 and sub.ps1. main.ps1 calls sub.ps1. Sometimes sub.ps1 throws an exception. Is it possible to catch the exception thrown by sub.ps1 from main.ps1 ?
Example main.ps1:
try{. .\sub.ps1;}
catch
{}
finally
{}
Example sub.ps1:
throw new-object System.ApplicationException "I am an ex...
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...
Hello,
I'm calling a powershell script from C#. The script is pretty small and is "gps;$host.SetShouldExit(9)", which list process, and then send back an exit code to be captured by the PSHost object.
The problem I have is when the pipeline has been stopped and disposed, the output reader PSHost collection still seems to be written to...
Hi,
as far as I understand, powershell has one profile per user. I would like to prepare multiple environments for different "hats" I could put on my head. Like start my "database worker shell" which provides a set of shortcuts for working with special databases. Later I would start an environment which might be my "data processing shel...
I am looking for a book or a site or something which will hit on the powershell scripting. NOT in command line.
I have a couple of scripts I need to write, writing an application is overboard, but the language is confusing. Programming conventions I am used to from php and C# seem to be thrown out the window on some things, like if stat...
Can someone explain to me why these comparisons work they way the do. I had a bug in one of my scripts that took me a little bit to work through. I was using read-host and typing a number. It was storing it as a string.
Write-Host "(`'2`' -gt 9 ) = " ('2' -gt 9 )
Write-Host "(2 -gt 9 ) = " (2 -gt 9 )
Write-Host "(`'2`' -gt 10 ) = " ('2'...
Hi all
I am using New-Object System.Management.Automation.PipelineStoppedException
To stop the pipeline OK..works..
But how Can I test in the next cmdlet if was stopped ?
Foo1 | foo2 | foo3
Stop in foo1, but goes to foo2. I want to test if was stopped in foo1 to stop too in each function
function foo1 {
process {
try ...