Sign In
Lessons Learned
My drop-site for interesting snippets and tips. If it's useful to you as well, great!
Translate This Page
Translate this page
Powered by
Microsoft® Translator
Options
Email Blog Author
RSS for posts
Atom
RSS for comments
OK
Search
Advanced search options...
Search In:
Everything
Blogs
Forums
People
Groups
Places
Pages
Date range:
All Time
Last Year
Last 6 Months
Last 3 Months
Last Month
Last Week
Last Two Days
Tags
Add-Member
Certificates
credentials
DateTime
Foreach-Object
Get-Alias
Get-Member
Group
LiveMeeting
MyInvocation
netsh.exe
New-Alias
One-Liner
password
PowerShell
PowerShell for N00bs
PowerShell for Non-N00bs
RegEx
Sort-Object
TechTips
tutorial
Unix
Where-Object
WMI
X509
Archive
Archives
February 2012
(2)
November 2011
(5)
October 2011
(6)
July 2011
(19)
June 2011
(14)
May 2010
(4)
March 2010
(1)
October 2009
(11)
September 2009
(11)
August 2009
(12)
MSDN Blogs
>
Lessons Learned
Posts
Subscribe via RSS
Sort by:
Most Recent
|
Most Views
|
Most Comments
Excerpt View
|
Full Post View
Lessons Learned
Clock Skew and You
Posted
3 months ago
by
timdunn
0
Comments
We had an issue where the clocks on various hosts got offset beyond the margin allowed by an application we were testing. Here's a way to scan hosts for their clock skew relative to a known good server: function Get-RemoteTime { param ( [ String [...
Lessons Learned
Set-ExecutionPolicy Fun
Posted
3 months ago
by
timdunn
0
Comments
Hm, I'm surprised this isn't included Out-Of-The-Box. Let's say I have a new deployment of machines and I need to set the ExecutionPolicy for each of them. Now, assuming I'm a domain admin, I should be able to do it remotely: Function Enable-PowerShell...
Lessons Learned
Accessing Performance Counter (for OCS A/V Edge Servers)
Posted
6 months ago
by
timdunn
0
Comments
OCS A/V Edge servers are somewhat wierd critters. One interface is load balanced, the other is accessed only by the trusted server list. The Load Balancer should be able to display the number of connections, but what about the internal interface? Say...
Lessons Learned
Batch-Unzipping Files
Posted
6 months ago
by
timdunn
0
Comments
Thanks to http://serverfault.com/questions/18872/how-to-zip-unzip-files-in-powershell/201604#201604 for the core code. Here's a function to unzip files, with rudimentary error handling, and ability to specify source and destination from the command...
Lessons Learned
Displaying an OCS Proxy Server's List of Trusted Servers
Posted
6 months ago
by
timdunn
0
Comments
Yesterday, we covered how to dump an OCS Edge Server's list of trusted servers, including using PSExec.exe as a workaround to it not exposing the list over remote WMI calls. It turns out the OCS Proxy Server uses a different WMI path, but it can be...
Lessons Learned
Displaying an OCS Access Edge Server's List of Trusted Servers
Posted
7 months ago
by
timdunn
0
Comments
Office Communications Server's Access Edge Servers and MediaRelay roles have a list of hosts they allow to connect on the internal interface. This is managed by the an administrative GUI accessed under ComputerManagement. GUIs are great for discoverability...
Lessons Learned
Certificates Owned by a Service
Posted
7 months ago
by
timdunn
0
Comments
PowerShell gives you access to certificates in many ways. You can read it in from a file, or look at it via the certificate: PsProvider, or, use .NET to open [System.Microsoft.Win32.RegistryKey] object. However, these don't tell the whole story. It turns...
Lessons Learned
Hash to Arrayof Objects
Posted
7 months ago
by
timdunn
0
Comments
As an old-time Perl user, I love hashes. In Perl, hashes are the answer, no matter what the question is. (No, not really, but they solve a lot of problems.) In PowerShell, hashes are cool, but you can't do things like "Sort-Object -property value". ...
Lessons Learned
Propagating Default Options
Posted
7 months ago
by
timdunn
0
Comments
Let's say I have a function that takes parameters, which all well-written ones should. And they have intelligent defaults, again as well-written ones should. The outer script exposes those parameters via the outer param() statement, but how do I pass...
Lessons Learned
No Reply All
Posted
7 months ago
by
timdunn
0
Comments
Short form: Go here http://research.microsoft.com/en-us/projects/researchdesktop/noreplyall.aspx Longer form: Outlook/Exchange, like so many other products, has some 'undocumented features', including a one-bit flag that allows reply-all or not. This...
Lessons Learned
Heavyweight Help in V1
Posted
7 months ago
by
timdunn
0
Comments
Again, in V1 PSH, this is what I use for nicely formatted help. If you're on V2, by all means, use the inline help, PLEASE! function Break-Line { # synopsis:: # [-help] # # Description:: # Inserts linefeeds into strings read from STDIN so they wrap...
Lessons Learned
Getting Remote Event Logs
Posted
7 months ago
by
timdunn
1
Comments
Quick and dirty wrapper for LogParser to download Event Logs
...
Lessons Learned
Quick and Dirty Help
Posted
7 months ago
by
timdunn
0
Comments
I like writing help text for my scripts. Yes, PSH V2 allows Get-Help to parse the inline help in scripts, but I'm stuck in V1 for my production environment. For quick-and-dirty scripts where I don't want to implement a 'real' help subsystem, I use the...
Lessons Learned
Why Use Semi-colons
Posted
10 months ago
by
timdunn
0
Comments
I get asked from time to time why I still put semi-colons at the end of each statement. Part of it is force of habit. Part of it is trying to make sure my script source is useful no matter how the web server, post edtior, and user's brower decide to display...
Lessons Learned
Abbreviated Key Names in Synthetic Properties
Posted
10 months ago
by
timdunn
0
Comments
The title is almost longer than the post. From Chris Dent's http://www.indented.co.uk/index.php/2010/01/12/powershell-iis-and-log-settings/ , I see that he's generating synthetic properties with Select-Object -Property @{n = 'name'; e = { "this...
Lessons Learned
A Loop of One
Posted
10 months ago
by
timdunn
0
Comments
Of late, I've been seeing some of my scripts do this: if (!(Test-Path file1)) { Write-Warning "File1 not found."; } else { do-something if (!(Test-Something)) { Write-Warning "Test-Something failed"; } else { do-something -part 2 if (!(Test-Something...
Lessons Learned
PowerShell and IIS Logs
Posted
10 months ago
by
timdunn
0
Comments
This is more of a pointer than an actual article. Chris Dent at www.intended.co.uk has a great post on getting IIS log settings from hosts here: http://www.indented.co.uk/index.php/2010/01/12/powershell-iis-and-log-settings/ The best part is how...
Lessons Learned
Getting Objects Out of AD
Posted
10 months ago
by
timdunn
1
Comments
This is dsquery.exe computer -name <foo> function Get-ComputerObjects { param ( [string] $name = "*" ); $directorySearcher = new-object DirectoryServices.DirectorySearcher([ADSI] "LDAP://$env:userDnsDomain" ); $directorySearcher .PageSize...
Lessons Learned
PSH V1 or V2?
Posted
10 months ago
by
timdunn
0
Comments
My lab has some machines that are only running PSH v1 (for reasons outside the scope of this article.) The easiest way is to try to run something that exists on V2, such as "import-module". However, the progamatic way is to get the ProductVersion property...
Lessons Learned
XPath and attribute value strings
Posted
10 months ago
by
timdunn
0
Comments
Quick note for my future reference - XPath1.0 evidently doesn't support wildcards nor regular expressions, but does have functions such as 'starts-with', 'contains', etc. $xml.SelectNodes("//nodeName[contains(@attribute, 'substring')]"); http:/...
Lessons Learned
Scanning for Binaries and Version
Posted
10 months ago
by
timdunn
0
Comments
I need to list the binaries installed to a folder and below for the software I’m testing. I can do that with Get-Command on each one, but this allows me to do it recursively and automagically. function Get-LocalBinaries { param ( [string[]] ...
Lessons Learned
Testing a Port
Posted
10 months ago
by
timdunn
0
Comments
Load blancers are great, but we don't get iAdmin access to them, so the only way we know if a host is down is to visually scan the web UI. And for whichever EIEIO security standard, we have two-factor auth which times out after a very aggressive interval...
Lessons Learned
Ignoring SSL Certificate Errors with WebClient
Posted
10 months ago
by
timdunn
0
Comments
First off, credit where credit's due. The incomparable Lee Holmes first tackled this in his blog: http://www.leeholmes.com/blog/2007/03/19/converting-c-to-powershell/ But I couldn't get it to work. Then I found Bhargav Shukla's method http://blogs...
Lessons Learned
"Manage Your Server" Welcome Screen
Posted
10 months ago
by
timdunn
0
Comments
Yeah, I'm still running 2003. In fact, I'm still asking the lab admins to build out new 2003 boxes. And when I log onto them, I get that next-to-useless "Manage Your Server" box. Here's how to blow it away in a cmd.exe or PowerShell.exe window: ...
Lessons Learned
Remotely Logging off RDP Sessions
Posted
10 months ago
by
timdunn
1
Comments
In our lab, we don't have Terminal Services Licensing set up. This means our servers have only 2 logon sessions per host. We have a GPO in place to log off non-console sessions after 24 hours of idle time, but we also have tradition of playfully chiding...
Page 1 of 4 (84 items)
1
2
3
4