I simply want to list all of the directories under my current working directory, using PowerShell. This is easy from a Bash shell:
ls -d */
or cmd.exe in Windows:
dir /a:d
Using PowerShell however I cannot seem to be able to do it with a single command. Instead the only the I've found that works is:
ls | ? {$_Mode -like "d*"}
Th...
I hate to say it, but powershell is really annoying me. I just cannot seem to get my mind around it. I have an O'Reilly book on the topic, and I can see how to do some extremely powerful stuff -- it's the easy stuff I can't seem to get right.
Case in point: Iterate across a list of filenames.
In CMD:
for /F %x in ('dir EXPRESSION') d...
I have a PowerShell script I use for creating distributions that copies compiled files from a few places and zips them up with winrar. In the script, I change to a directory containing the folders I want to run and execute this:
Invoke-Expression ($WinRAR + " a " + $zipPath + " " + $WinRARFilter + " " + $DistName + "-zip " + $WinRAROpts...
When I call a Powershell script, how can I keep the called script from closing its command window. I'm getting an error and I'm sure I can fix it if I could just read the error.
I have a Powershell script that sends an email with attachment using the .NET classes. If I call the script directly by executing it from the command line or ca...
I am creating an array of string objects in PowerShell which needs to be passed into an Xceed zip library method which expects a string[], but I get an error everytime. It makes me wonder if the PowerShell array is something other than a .NET array. Here is some code:
$string_list = @()
foreach($f in $file_list)
{
$string_list += $f.Fu...
I'm working on debugging a Powershell project. I'm using Import-Module to load the PS module from my C# dll and everything works fine. Calling Remove-Module does not fully unload the module though as the DLL is still locked and can not be deleted.
Is there a way to get PSH to fully unload the module and release the DLL so that I can c...
In Powershell I am defining a new PSDrive called test. But when I type test: at the console it throws an error. If I type cd test: it works fine.
Shouldn't I be able to navigate to the test drive just by typing test:?
PS> New-PSDrive -name test -psprovider FileSystem -root C:\test
WARNING: column "CurrentLocation" does not fit into ...
Pardon me if this is too simple a question, but I'm not finding anything in the help files or online so far regarding doing this. I'm opening up a new browser window to test the login/logout feature of a web based application, but I want to open the IE window in maximized mode. I could set the size as:
$ie.height = 1024
$ie.width - 768...
I'm looking for different examples of custom Powershell prompt function implementations. If you have a custom implementation of your own please post the script. Links to existing resources are good as well.
Bonus points for posting a screenshot of what your prompt actually looks like (a preview).
...
I'm trying to figure out how I can open a ps1 script (or any file) in PS ISE by using the $psISE object.
How can I open a document tab in PS ISE from the command line in PS ISE itself (without using File > Open)?
...
I have two machines Server A and Server B I want to copy all the files and folder tree from Server A to Server B and create the same file and folder tree using powershell scripting
I have tried the command given below but it copies only the files in the folder but do not create the folder tree
Copy-Item E:\TestSource\* //TestDestinati...
Hi,
I need to identify the P(rocess) ID of an executing batch file from a PowerShell (v1.0) script. Can anyone suggest a way of doing this?
Thanks, MagicAndi.
...
I used to use a different source control tool and it allowed me to get a "diff report": all the changes made to a file between version X and version Y (including lines added/removed between each version, which could be many versions) in one text file. It was pretty handy for situations where you are pretty sure that some code used to be ...
If I find (or create) a new PowerShell cmdlet (or function), how do I add it to my machine?
Do I copy it to a particular folder?
Do I put its content in a particular file?
Do I need to authorize it, or sign it, or give it permission in some way?
I don't want to use it in just one session, I want it to be available whenever I use Powers...
I've just recently completed my first nightly build script (first significant anything script, really) in powershell. I seem to have things working well, if not yet robustly (I haven't handled significant error-checking yet), but I found myself falling into an idiom around the Invoke-Expression cmdlet, and I'm wondering if I'm using it ...
I have two servers Server A and Server B i want to Stop server A from Server B remotely using powershell script
Can anybody help me on this its urgent.
Thank you in advance
...
Hi All,
I'm in a situation where I need to deploy around 200 SSL Certificates to various devices around our Agency (HP iLO - such joy they bring...). At present I have a powershell script that obtains a CSR from the iLO Device, but I now need to be able to sign this with our CA in an automated manner so I can pass back to the script and ...
I need to use the SharePoint API in the following way in a PowerShell script:
C# Code:
var service = farm.Services.GetValue<SPWebService>();
How does one specify the generics parameter in PowerShell?
At the moment I get an Exception stating that "Late bound operations cannot be performed on types or methods for which ContainsGenerei...
How can I make zip etc. files appear as folders in powershell? Does PowerShell have a concept of folder (item) providers akin to drive providers? Can this be done without implementing a drive provider?
Preliminary search turns up some useful information but from the looks of it, it appears that I still need to implement the whole sheban...
I should probably not ask a generic question with a specific example, but I have a hard time translating some basic commands from the PowerShell console to reusable functions and custom cmdlets. Is there a definitive guide to the syntax of PowerShell somewhere, with gotchas, hints and tips?
For instance, I'm trying to create a function ...