PowerShell variables are inherited downstream by default, not upstream. So any variable you create at a given scope is passed to any code you call...
database-tools
Do You Use "Break"?
"Break" is a special keyword that you can use to exit loops and conditions prematurely. Have a look: Do { $pwd = Read-Host 'Enter your...
Change ErrorAction for Your Private Error Handling
When you handle errors yourself using Trap or try/catch, you should make sure that you set your ErrorActionPreference to "Stop" or specify...
Deleting Error Records
In a previous tip, you learned that "Continue" can skip code in a loop. Another scenario for using "Continue" is error handling....
Using ‘Continue’
You will find that "Continue" is a special instruction that you can use in loops to skip the remainder of a loop. This next loop returns...
Getting PowerShell Team Blog Topic Headers
In a previous tip, you learned how to use RegEx to scrape information from Web pages. It really is just a matter of finding the right...
Move Groups Of Tables
I've just started to use the Schema Designer feature, and whilst handy it is driving me mad as I can't see any way of moving a group of...
Scraping Information from Web Pages
Regular expressions are a great way of identifying and retrieving text patterns. Take a look at the next code fragment as it defines a RegEx engine...
Download Web Page Content
Probably the easiest way of reading raw Web page content is using the Web client object. This will read the Web content of...
Write-Output is Picky
Assigning (multiple) return values with Write-Output works well, but you should keep in mind that Write-Output is picky and returns the exact thing...
Do You Know Write-Output?
When you leave data behind, PowerShell automatically returns it to the caller. This may create strange-looking code. With Write-Output, you can...
Use Write-Cmdlets with Care!
There is a fundamental difference between outputting data using Write-Host and just "leaving info behind":" Function test {Write-Host...
Opening Event Log GUI
In a previous tip, you learned how to register event log sources and write your own event log entries. With Show-Eventlog, you can easily open the...
Creating New Event Logs
Logging information to your event log is easy when using Write-Eventlog. You will just need to register your own event source first by using...
Running Commands Elevated
You can launch a separate PS environment and elevate it Iif you are running your script in a restricted environment and want to run a...
Prompting for Secret Passwords via Console
Whenever you need to enter credentials, you can either use Get-Credential or a low- level PS API function like so: $c =...
Take your indexed columns out of functions to really boost SQL Server performance!
In a future article I will show how to quantify and rank your “heaviest” SQL Server queries according to the overall load they place on...
Prompting for Secret Passwords via Console with Powershell
You can use Read-Host to hide user inputs for safe password prompts: $pwd = Read-Host -AsSecureString 'Enter Password'Enter Password: ******...
Prompting for Passwords
If you need to prompt for a secret password and do not want it to be visible while entered, you should use Get-Credential. This cmdlet returns a...
Performance of COALESCE vs. IS NULL
There are a great many articles out there expounding the virtues of using the ANSI standard COALESCE function over the...
Finding Static Methods
You will find that types can contain very useful methods. To get a list, you can pass the type to Get-Member, but do not forget to specify the...
Identifying 64-Bit-Environments
You will find that one great advantage of 64bit-Environments is the address width of 8 bytes instead of 4 bytes. You can use this to identify...
Finding Maximum Values
Numeric types can store numbers in certain ranges. A byte for example stores values in the range 0-255. But do you know just what the range is for...
Monitoring Disk Space Of Nas Devices
I have 3 different NAS devices (Netgear, Lacie, IOmega) that I would like to monitor through uptime to see if their disk space is being used or...