Hello,
I created a powershell object via .net to invoke commands.
When I invoke normal commands like 'Get-Process' I had no problems:
ps.AddCommand("Get-Process").AddParameter(...).Invoke()
but I'm not able to invoke a .net method with the syntax "[namespace.class]::method", just to make an example to invoke [System.IO.File]::Exists(...
Is there any shorter way of doing this in Powershell v2.0?
& { $a = 1 ; & { $a = 2 ; & { get-variable -name a -scope 2 } } }
... like, for instance, this?:
& { $a = 1 ; & { $a = 2 ; & { $2:a } } }
...
Hi,
I wrote Powershell script to copy a worksheet from a workbook A to another workbook B. The worksheet contains define names for ranges within that sheet. Originally, the defined names are global in workbook A, ie. can be referenced from any worksheets within workbook A.
But now, after copy to worksheet B, the defined names are limit...
I want to type directly into the Powershell prompt too, not pipe in a text file.
Foo`r doesn't work for me. For example:
echo "RJ`r`n" | .\nc.exe -u 192.168.1.247 2639
but what I'd really like to do is just
.\nc.exe -u 192.168.1.247 2639
then start typing into the prompt.
...
This expression seems to work:
gci . | % { gc $_}
This also seem to work as well (I suspect it is a little slower):
gci . | Select-String .
Is there a better way of writing a expression to dump all lines from all files out in a directory?
Thanks
...
How to find the depth of the xml file using powershell/xpath?
consider the below xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book>
<title>Harry Potter</title>
<price>25.99</price>
</book>
<book>
<title>Learning XML</title>
<price>49.95</price>
</book>
</bookstore>
depth of the above xml document is 3 (bookst...
Folks, I'm using git tools such as git bisect run which need to call a command to build and test my project. My command to do is nant which is a windows program. Or a build.cmd script which calls nant.
It's easy to get the bash to call the nant build to run.
But the hard part is how to get the standard output written to a file?
I eve...
Can I use a variable in and LdapFilter with Get-QADComputer? i.e.:
$31DaysAgo = (Get-Date).AddDays(-31)
$ft = $31DaysAgo.ToFileTime()
$StComps = Get-QADComputer -SizeLimit 0 -IncludeAllProperties -SearchRoot `
'DC=MY,DC=DOMAIN,DC=LOCAL' -LdapFilter '(&(objectcategory=computer) `
(pwdLastSet<=$ft)(|(operatingsystem=Windows 2000 Profess...
It seems like ASP.NET WebMethods are not "web servicey" enough to work with New-WebServiceProxy. Or maybe it is, and I haven't figured out how to initialize it?
So instead, I tried doing it manually, like so:
$wc = new-object System.Net.WebClient
$wc.Credentials = [System.Net.CredentialCache]::DefaultCredentials
$url = "http://www.dom...
I have a FileSystemWatcher instance running in the background of my PoSh session watching for changes to text files. A PoSh event subscriber is attached to this event and, when fired, it launches a console program by calling Start-Process. This program steals de focus from the current foreground window (my PoSh console). Calling SetForeg...
We want to activate the existing future for more than 100+ site-collections, what would be the right choice? can we achieve this through Powershell?
...
I've written a PowerShell script to build several .net solutions one after the other. It simply makes several calls to tfget (to get latest) followed by devenv.exe (to build the .sln files).
Here's the code:
tfget -item $SolutionPath -overwrite -recurse -ev +errors
...
$out = invoke-expression "devenv.com /rebuild debug $SolutionPath"
...
I am writing a script in Powershell to get the update information from each computer and correlate the information with another System which identifies updates by CVE ID. I have discovered that there is a "CVEIDs" property for an update in WSUS, which is documented in MSDN, but I have no idea how to access the property. Retrieving the CV...
I have PowerShell v2.0 installed and on top of that, PSCX is installed. PSCX is the PowerShell Community Extensions (http://pscx.codeplex.com/Wikipage).
It seems that I have two cmdlets called Start-Process installed and I'm guessing one is the original and the other is from PSCX. When I invoke Start-Process, the PSCX cmdlet is made to...
Question
What would be a good (ideally, technical) reason to ever program some non-trivial task in dos batch language on a modern Windows system as opposed to downloading either PowerShell, or ActiveState Perl?
To be more specific, I make the following two assumptions for the duration of this question:
anyone technical enough to be a...
In inetmgr you can set the property I desire by going to Home Directory -> Application Settings -> Execute Permissions -> and setting the drop down to 'Scripts Only'. I'm trying to replicate this behavior in Powershell. The Target OS is Windows Server 2003 running IIS6.
Currently I have this simple code to get the site:
$Site = get-wmi...
Hi,
In old DOS script, I can run an R script with the following syntax:
Rterm.exe --quiet --slave --vanilla < "C:\some_script.R"
However, Powershell seems to have reserved "<" for future expansion. I am wondering if there is a direct way to run R script within another powershell script.
Thanks
...
Can i skip multiple lines with the -skip option?
gc d:\testfile.txt | select -skip 3
works but what to do if i want to delet line 3-7 ??
...
I'm writing a GUI tool using PowerShell that is able to do most AD related tasks with just a user name and button click. I've done all the usual ones (Create / Remove Users, Create / Remove Security & Distribution Groups, Resetting Passwords, etc) but can't find away of unlocking a "Locked Out" account.
I'm trying to do this without usi...
Hi there,
I'm looking to calculate the total size of all shared folders (except admin shares) on a number of different servers (consolidating all accessed files to a NAS box for easier backup / restore) but am having a bit of trouble finding a solution.
I'm certain this could be done in powershell but I just can't find the right inform...