Hi,
I would like to know if their is a method which I can call which can tell me if a PowerShell
snapin is installed.
I know I could call probably do it, say via WMI or write a PowerShell script and return a list to C#, but is their not a method do it somewhere.
Thanks.
...
Hi fellow pythonistas, there seems to be a problem when virtualenv is used in PowerShell.
When I try to activate my environment in PowerShell like..
> env/scripts/activate
.. nothing happens. (the shell prompt should have changed as well as the PATH env. variable .)
I guess the problem is that PowerShell spawns a new cmd. process jus...
Is there any way a batch script can know if it's called from PowerShell (without extra parameters feeded)?
Need something like..
if (%THIS_BATCH_CALLED_FROM_POWERSHELL%)
... warn the user or drop back to powershell to execute the proper instructions...
Question related with this question - virtualenv-in-powershell.
...
Here is a blog post from Kirk Munro that explains how a script can set the DefaultDisplayPropertySet on its output objects:
Essential PowerShell: Define default properties for custom objects
His technique and example code doesn't appear to work in PowerShell v2. (Note, I have PowerTab and PSCX installed--perhaps those could be interfer...
I'm just learning PowerShell and I've written a script that will be used for archiving log files from a server. I'm in pretty good shape with everything but the recursiveness or not of get-childitem...
The issue I seem to be having is that when Get-ChildItem is not recursive and -Include is present with only one filter, it is ignored! ...
Is there a way to disable and re-enable a known TCP/IP port in PowerShell?
...
I'm trying to get PowerShell to copy files from a remote computer (on which I have admin rights through AD) to the local computer.
It fails in the strangest place. Here's a snippet of the script:
$configs = Get-ChildItem -Recurse -ErrorAction SilentlyContinue -Filter "*.config" $serverUNCPath
foreach($config in $configs){
$config_...
The Rename-Item accepts a scriptblock (I think...) as a parameter so I can do something like this if I want to rename a bunch of files (for example):
Dir *.ps1 | Rename-item -NewName {$_.Name -replace ".ps1" ".txt" }
I'm writing a cmdlet to rename some items and would like to be able to use syntax like this for the new name, but how t...
Hi All,
I'm a sys admin and I am trying to learn how to use powershell... I have never done any type of scripting or coding before and I have been teaching myself online by learning from the technet script centre and online forums.
What I am trying to accomplish is to open an excel spreadsheet get information from it (usernames and pas...
I can't understand why I'm seeing this behavior in Powershell:
PS C:\> trap { "Got it!" } 1/0
Attempted to divide by zero.
At line:1 char:22
+ trap { "Got it!" } 1/0 <<<<
PS C:\> trap { "Got it!" } 1/$null
Got it!
Attempted to divide by zero.
At line:1 char:22
+ trap { "Got it!" } 1/$ <<<< null
Why does one expression trigger the tra...
I played around with PowerShell yesterday, and it seemed pretty nice ( the GUI at least ). Is it worth getting to know the language? I'm pretty proficient in Ruby/Python/Perl/Groovy when it comes to scripting languages, so I think the fact that PowerShell is a scripting language isn't a bonus here.
Another thing I didn't like was that P...
I'm trying to use the PowerShell Add-Member cmd on all the items in an array and then access the member I added later but it doesn't show up.
You can see in the output of the below code that the NoteProperty appears to exist within the scope of the foreach statement but it doesn't exist on the same object outside of that scope.
Any way...
I have the following PowerShell function that works well for any input except for 1. If I pass it an input of 1 it will return an array with two elements 1,1 instead of a single element which is itself an array of two elements (1,1).
Any ideas how I can make PowerShell return a jagged array with one element that is itself an array?
fu...
How can I remove duplicates from a PowerShell array.
$a = @(1,2,3,4,5,5,6,7,8,9,0,0)
...
Say i have cmdlet1 and cmdlet2, both are long running tasks. Normally i would have a batch file which calls the two cmdlets in order:
call powershell cmdlet1
call powershell cmdlet2
Is there anyway to set them off asynchronously?
...
Is there a way for a PowerShell job to report progress or to trigger events before it is complete? I just started playing around with executing background jobs in PowerShell and am wondering how far I can push the capability.
...
I have a script that runs an external exe. When that exe fail (sets errorlevel to 1), the powershell script fails.
I'm running curl.exe and getting this: + CategoryInfo : NotSpecified: ( % Total % ... Time Current:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError
How can I ignore/catch the failure of the externa...
I am trying to get all of the CN's out of active directory in order to populate groups based on that name into Sharepoint Services. I can list the "memberof" section but I can not seem to split it using split(",")
$Dom = 'LDAP://OU=External,OU=Users,OU=HomeOffice,DC=mydoman,DC=com'
$Root = New-Object DirectoryServices.DirectoryEntry $D...
I have a powershell script that contains several function.
How do I invoke, from the command line, a specific function?
This doesn't work:
powershell -File script.ps1 -Command My-Func
...
I want to be able to output data from Powershell without any column headings. I know I can hide the column heading using Format-Table -HideTableHeaders, but that leaves a blank line at the top.
Here is my example:
get-qadgroupmember 'Domain Admins' | Select Name | ft -hide | out-file Admins.txt
How do I eliminate the column heading ...