I just got a project where I have to do the following on a Windows OS:
detect how many drives (C: D: E:
..etc) are connected to current
system
what the system labels are
for each volume
how much storage
(both used and free) for each of the
drives
what format each drive is
(NTFS/FAT32)
how many files are
in a given directory in any o...
Hi,
I'm trying to read the event log for security audit for all users except two, but is it possible to do that with the -notlike operator? It's something like that:
Get-EventLog -LogName Security | where {$_.UserName -notlike @("*user1","*user2")}
I have it working for a single user, like:
Get-EventLog -LogName Security | where {$_....
Dear Friends,
I am developing a .NET/C# 2.0 application which uses the PowerShell SDK for script execution. I am not using SnapIns. I am setting everything directly through PS's RunspaceConfiguration.
So my problem is that I cannot add a custom format for my type Plux.ExtensionTypeInfo implemented in the application.
( Plux.Extensio...
Linux allows me to have a short system path by placing binaries in just a few locations. I don't have to edit the path because I just installed a new application, and I don't have to hunt for applications I want to run. How can I, with PowerShell as the program I use to launch programs from, accomplish the same thing on Windows (Vista)?
...
The powershell guidelines suggest avoiding the use of aliases in scripts, e.g. spelling out Get-Content instead of using gc, and using Foreach-Object instead of %.
For the most part I think this is good advice, but I'm having a hard time following it with the dir alias, at least when used with the filesystem (vs. the registry or such). ...
I need to create a virtual directory within an IIS Site pointing at a network share \\servername\sharename\directory and I need to specify a specific user for the Pass-through authentication.
I am after the WMI script to do this which I intend to call from a Powershell script.
Although the target IIS environment is IIS7 (WMI namespace ...
How can I get a "du" -ish analysis using powershell?
I'd like to periodically check the size of directories on my disk.
The following gives me the size of each file in the current directory:
foreach ($o in gci)
{
Write-output $o.Length
}
But what I really want is the aggregate size of all files in the directory, including subdir...
I have this idea that I should switch over from cmd.exe to powershell. It's so much more powerful than the tried and tested cmd.exe. It is the shell of the future for Windows.
But my facility in powershell is so limited, in comparison with cmd.exe. Around every corner I discover another seemingly small obstacle that is insurmountable...
I've just tested this on PowerShell v1.0. Setup is as follows:
Id CommandLine
-- -----------
1 $msbuild = "C:\Windows\Microsoft.NET\Framework\v3.5\msbuild.exe"
4 $a = "C:\some\project\or\other\src\Solution.sln /target:Clean /target:Build"
.
This line fails with an unintuitive error message:
Id CommandLine
-- -----------
5 ...
Is there any reason to use the "Param( ... )" construction inside a function definition? My understanding is that you should use this for specifying parameters to scripts (and scriptblocks). I see a lot of examples on the web with parameters listed this way instead of just listing the parameters after the function name.
Example:
f...
Hi,
I'm building a script to read the Security Log from several computers. I can read the Security log from my local machine with no problem when using the Get-EventLog command, but the problem with it is that I can't run it against a remote machine (the script is for powershell v1). The command below never returns any results, although ...
I'd like to use PowerShell as part of our automated build process to update an App.config file while deploying into our test environment. How can I do this?
...
Can I use powershell as the shell, in shell mode for emacs?
How?
...
I use the automation interface of Internet Explorer from Powershell to open a web page in a supported format. I want to save this page back to disk in one of the formats supported by IE. Opening the page is easy:
$ie = New-Object -ComObject "InternetExplorer.Application"
$ie.Navigate("C:\MyFile.mht")
How do I save it back in another f...
I'm exporting PowerPoint presentations using PowerShell. This works fine with the Office XPS/PDF exporter plugin. However, only the complete slide, without animations, are exported.
When exporting a presentation as a web page, the presentation can be run step-by-step (e.g. revealing bullet points one by one) if you check the "Show slide...
I need to download and install about 50 CRLs once a week and install them on several Windows servers. Downloading is the easy part, is there a way I could script the CRL import process?
...
This will set the value, but will not cause a postback:
function SelectValue($ddl, $val) {
$ddl.options | % {$i = 0}{ if ($_.value -eq $val) {
$ddl.selectedIndex = $i; }; $i += 1; }
}
Also, once I get the postback working, will I need to add a delay, eg:
while($ie.ReadyState -ne 4) {
start-sleep -m 100
...
Is there a way to use PowerShell to view the contents of the GAC?
...
I am trying to write a Powershell script that can get pipeline input (and is expected to do so), but trying something like
ForEach-Object {
# do something
}
doesn't actually work when using the script from the commandline as follows:
1..20 | .\test.ps1
Is there a way?
Note: I know about functions and filters. This is not what I...
The default TabExpansion in Powershell cycles through the possible completions for the fragment on the command prompt. Internally in the PowerShell host, there's a circular buffer, and the first TAB fills the buffer and puts the first potential completion on the prompt. Subsequent TABs cycle through the list of possible completions.
...