Hi,
I've got a scipt executing in C# using the powershell async execution code on code project here:
http://www.codeproject.com/KB/threads/AsyncPowerShell.aspx?display=PrintAll&fid=407636&df=90&mpp=25&noise=3&sort=Position&view=Quick&select=2130851#xx2130851xx
I need to return the $lastexitcode and Jean-Paul...
Can anyone give me some pointers on how to set permissions on MSMQ queues in script, preferably PowerShell, but I'd use VBscript
...
I have a powershell script that modifies transport rules. It works perfectly from powershell and I want to create a web interface so non-tech bods can edit transport rules (specifically, redirections) but when I try and run it from a .net website, the set-transportrule command seems to be ignored. The script is:
$rule = "Redirect -> " +...
The following PowerShell code loads a SQL result into a dataset:
$sqlCommand = "SELECT A, B FROM TestTable"
$connection = New-Object System.Data.OleDb.OleDbConnection $connectionString
$command = New-Object System.Data.OleDb.OleDbCommand $sqlCommand,$connection
$connection.Open()
$adapter = New-Object System.Data.OleDb.OleDbDataAdapter ...
$args returns only optional arguments. How can I get all function parameters?
...
Hi,
I have a Windows Forms app that provisions user accounts in Exchange using Powershell and Exchange2007 cmdlets. There is only one form to this application that takes the information for the new user and then runs the Powershell commands. Like a good programmer, I just refactored the code and took all the Exchange and Active Director...
Is it possible to get PowerShell to always output / instead of \? For example, I'd like the output of get-location to be C:/Documents and Settings/Administrator.
Update
Thanks for the examples of using replace, but I was hoping for this to happen globally (e.g. tab completion, etc.). Based on Matt's observation that the separator is de...
What's the fastest way using either DOS scripting or PowerShell to run this simple command on a directory and all its subdirectories:
convert filename.jpg -resize 620x620 "R:\processed\filename.jpg"
DOS Batch script for single directory:
FOR %%a in (*.jpg) DO convert %%a -resize 620x620 "R:\processed\%%a"
I want to run this recur...
Curious, what is the idea behind this:
@() -as [bool]
# False
@($null) -as [bool]
# False
@($null, $null) -as [bool]
# True
I would expect either False/True/True or False/False/False, but not False/False/True.
...
I use Write-Host analyze objects, but some times it is hard to understand what the object actually is.
Consider:
Write-Host $null
Write-Host @()
Write-Host @($null, $null)
Prints:
# Actually it prints nothing
I would like some thing like this:
Null
@()
@(Null, Null)
Any suggestions?
...
I am wondering whether anyone came up with good use cases of the $^ and $$ automatic variables in Powershell. At the moment I am not seeing much use for them, at least from a programmer perspective.
When using PS interactively and executing a long command you could use .$^ to repeat it and with $$ you could get the last argument, but .$...
From documentation:
-Include
Retrieves only the specified items.
The value of this parameter qualifies
the Path parameter. Enter a path
element or pattern, such as "*.txt".
Wildcards are permitted.
The Include parameter is effective only when the command
includes the Recurse parameter or the
path leads to the ...
I've got a simple Bash command to resize some images automatically on a low-traffic website using ImageMagick - I'd like to convert this to a PowerShell command so I don't have to install Cygwin on my webserver. Can anyone lend their PSh skills here?
ls | xargs -I {} rconvert "{}" -resize 128x128\> "{}"
...
Runing such script:
1: function foo()
2: {
3: bar
4: }
5:
6: function bar()
7: {
8: throw "test"
9: }
10:
11: foo
I see
test
At C:\test.ps1:8 char:10
Can I get a detailed stack trace instead?
At bar() in C:\test.ps1:8
At foo() in C:\test.ps1:3
At C:\test.ps1:11
...
How could one find the 10 largest files in a directory structure?
...
Documentation states:
Adds a user-defined custom member to
an instance of a Windows PowerShell
object.
What "Windows PowerShell object" stands for?
This works fine:
$obj = new-object system.object
$obj | add-member -membertype noteproperty -name Name -value "OK"
$obj.name
But this does not:
$obj = @{}
Actually, I am tryi...
I'm attempting to read a value from a registry entry with Powershell. This is fairly simple, however, one particular registry key is giving me trouble.
If I run the following, I can't get the value of the (default) of "$setting".
C:\Program Files\PowerGUI> $setting = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\Curren...
I am new to PowerShell, I am trying to change a property of an IIS website using the following syntax (which doesn't work)
(get-item 'IIS:\Sites\Default Website').logFile.directory = 'd:\'
It doesn't show any error but doesn't change the property either.
Anybody help?
...
I have a task: files available over WebDAV on a remote server (SSL required) must be checked for whether they may have been updated recently, and if so copied to a local folder. There are a number of other actions that need to be performed after they arrive (copied to other folders, processed, etc.). The operating system I'm working from...
I have created a couple of PowerShell scripts which configure computers used in a training class. Some classes need to connect to a different wireless network (SSID). I can just instruct users how to use the windows XP facilitites to change the network they are connected to but I would like to be able to roll the network selection in t...