I'm using the CTP of powershell v2. I have a script written that needs to go out to various network shares in our dmz and copy some files. However, the issue I have is that evidently powershell's cmdlets such as copy-item, test-path, etc do not support alternate credentials...
Anyone have a suggestion on how best to accomplish my task.....
I need to run a Get-Mailbox | Get-MailboxStatistics command across a large number of mailboxes but the majority have never been used as it is a new install. As a result, I have to sit through hundreds of lines of
WARNING: There is no data to return for the specified mailbox '<mailbox DN>' because it has not been logged on to.
It woul...
Hi guys,
Im abit of a noob to Powershell so please dont chastise me :-)
So I've got some rather large log files (600mb) that I need to process, my script essentially strips out those lines that contain "Message Received" then tokenises those lines and outputs a few of the tokens to an output file.
The logic of the script is fine (alth...
I have a text file containing lines of data. I can use the following powershell script to extract the lines I'm interested in:
select-string -path *.txt -pattern "subject=([A-Z\.]+),"
Some example data would be:
blah blah subject=THIS.IS.TEST.DATA, blah blah blah
What I want is to be able to extract just the actual contents of the ...
Provide one line PowerShell script that you found useful, one script per answer please.
There is a similar question here, but this one gives only links to pages with scripts, lets answers one by one here and have a contributed list of most frequently used or most useful scripts.
1.List most recent version of files
ls -r -fi *.lis | s...
Hi Guys,
Im trying to join a number of elements of an array into a string using this;
$a = "h","e","l","l","o"
$b = [string]::join("", $a[0,1,2,3])
But I get a 'Missing ')' in method call' error. The join documentation only mentions joining all the elements of an array, not elements at specific indexes. Can this be done?
Cheers
And...
Hi, I've got a list of files in an array. I want to enumerate those files, and remove specific files from it. Obviously I can't remove items from an array, so I want to use an ArrayList.
But the following doesn't work for me:
$temp = Get-ResourceFiles
$resourceFiles = New-Object System.Collections.ArrayList($temp)
Where $temp is an Arr...
The following code gives me an array of PSCustomObjects, how can I get it to return an array of Strings?
$files = Get-ChildItem $directory -Recurse | Select-Object FullName | Where-Object {!($_.psiscontainer)}
(As a secondary question, what's the psiscontainer part for? I copied that from an example online)
Post-Accept Edit: Two grea...
I'd like to pass an associative array from C# to Powershell. As an example I'd like to execute this powershell line of code:
PS C:\> get-command | select name, @{N="Foo";E={"Bar"}} -first 3
Name Foo
---- ---
Add-Content ...
What are the some of the PowerShell tips & tricks that you use to increase your productivity as a .NET developer?
...
When I was a Linux admin I could do anything from the SSH command line. Now, as a Windows admin, I have to deal with the Windows Remote Desktop graphical interface, which I found to be inefective (slow) and hard to automate tasks in it.
a) Can I connect to a Windows Server through SSH or any encrypted connection with command line interf...
Hi Guys,
Im trying to run some logparser commands from powershell but Im having issues with passing the arguments across correctly, heres the excert from my script;
d:\scripting\smtplogs\logparser\logparser.exe "SELECT TOP 50 Receiver, COUNT() INTO %TMPOutput%\TopReceiversNDRALL.gif FROM %TempDir%\PostAll.log WHERE Sender LIKE '<>' AND...
I was testing PowerShell remoting:
I installed PowerShell V2 CTP3 on my Windows XP desktop
I installed WS-Management v1.1 on my Windows 2003 R2 server, which has its firewall disabled and no PowerShell installed.
Both machines have .NET Framework 3.5 SP1
When I type on my desktop:
Get-WmiObject -ComputerName computerNameHere Win32_S...
If you launch a 32-bit instance of Powershell (%SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe), then the registry provider only sees the limited 32-bit parts of the registry.
**32-bit console**
PS> (dir HKLM:\SOFTWARE | measure).count - (dir HKLM:\SOFTWARE\wow6432node | measure).count
0
**64-bit console**
PS> (dir HKLM:\S...
I want to use YUI Compressor to combine and compress my css and js file sets when I compile my project. YUI Compressor only takes as input single files. I've tried using the following (Windows) commands to append to the output files, but strange characters appear in the output where appendage occurs. How can I use windows command line or...
Scenario.
3rd party admins want to administer systems with PS remoting/direct login of clients and servers behind NAT gateways.
The systems are SBS 2003 or W2K3. all are behind NAT firwalls with varying RFC1918 subnets and no site to site VPNs (although a solution would likely require this.)
Each site has its own unrelated AD setup.
...
I have a PSHost object executing a Powershell script myscript.ps1 and that .ps1 script is executing sqlcmd.exe to get what it needs done. Is there a way to keep it from popping up empty sqlcmd dos prompts (as it seems to do)?
...
I am now starting to use PowerShell and after a lot of time using the Unix shells and want to know how to check for the existence of a file or directory.
In Powershell why does Exist return false in the following expression?
PS H:> ([System.IO.FileInfo]"C:\").Exists
False
And is there a better way to check if a files is a directory t...
Hi Guys,
So Im being a bit anal here but I cant get add-content to add both a string and the output of a cmdlet so it would look something like this;
Add-content -path $logfile -value "This is my text"+(Get-Date)
I realise I can just add another line to set a variable to the result of get-date but and then pass the variable into my ad...