5 Different Ways to Start SQL Server Services

5 Different Ways to Start SQL Server Services

If nothing works, then a restart works. This is the exact sentiments that an Administrator has when it comes to working with software. If you are working as SQL Server DBA, you must have done this many times – restart SQL Server Services. It’s always interesting to...

Disable Scientific Notation for Sybase ASE FLOAT Data

Getting the Number of Lines in a String

All PowerShell Versions Here is a clever trick how to find out how many lines a string (not a string array!) contains: $text = @' This is some sample text Let's find out the number of lines. '@ $text.Length - $text.Replace("`n",'').Length...

Disable Scientific Notation for Sybase ASE FLOAT Data

Finding Minimum and Maximum Values

All PowerShell Versions To find the smallest and largest item in a range of numbers, use Measure-Object: $list = 1,4,3,1,3,12,990 $result = $list | Measure-Object -Minimum -Maximum $result.Minimum $result.Maximum This works for any input data and any data type. Here...

Disable Scientific Notation for Sybase ASE FLOAT Data

Getting Files with Specific Extensions Only

All PowerShell versions When you use Get-ChildItem to get a list of files, you may have noticed that the -Filter parameter occasionally returns more files than you’ve expected. Here is an example of this. This line does not just return files with a...

DBAs and Dinosaurs

DBAs and Dinosaurs

You have to admit that title is catchier than yet another “Death of the DBA” blog.  And that was exactly the direction I was headed until I ran a quick search to find a reference that not only exposed actual predictions of the death of the DBA as a profession but...

Disable Scientific Notation for Sybase ASE FLOAT Data

Testing UNC Paths

Test-Path can test whether or not a given file or folder exists. This works fine for paths that use a drive letter, but can fail with pure UNC paths. At its simplest, this should return $true, and it does (provided you did not disable your administrative shares):...

Disable Scientific Notation for Sybase ASE FLOAT Data

Exporting and Importing Credentials in PowerShell

Credential objects contain a username and a password. You can create them using Get-Credential, and then supply this object to any cmdlet that has the -Credential parameter. However, what do you do if you want your scripts to run without user intervention yet...

Disable Scientific Notation for Sybase ASE FLOAT Data

Use $PSScriptRoot to Load Resources

Beginning in PowerShell 3.0, there is a new automatic variable available called $PSScriptRoot. This variable previously was only available within modules. It always points to the folder the current script is located in (so it only starts to be useful once you actually...

Disable Scientific Notation for Sybase ASE FLOAT Data

Changing FireMonkey style at runtime

Last month Sarina DuPont blogged about loading custom FireMonkey styles on a mobile device at runtime ("How to load custom styles at runtime"). That's a very interesting approach to compile a custom style as a resource into the mobile app. This week...

Disable Scientific Notation for Sybase ASE FLOAT Data

Getting More Than 1000 Active Directory Results

By default, Active Directory returns only the first 1000 search results when you use an ADSISearcher. This is a security mechanism designed to prevent unspecific LDAP queries from causing domain controller load. If you do need all search results and know that it will...

Disable Scientific Notation for Sybase ASE FLOAT Data

Converting Binary SID to String SID

Converting SID from Binary to String Active Directory accounts contain the SID in binary form. To convert the byte array into a string representation, use a .NET function like this: # get current user $searcher =...

Disable Scientific Notation for Sybase ASE FLOAT Data

Converting Excel CSV to UTF8

When you export Microsoft Excel spreadsheets to CSV files, Excel by default saves CSV files in ANSI encoding. That's bad because special characters will break once you import the data into PowerShell using Import-Csv. Ensuring UTF-8 Encoding for CSV Files To make sure...

Disable Scientific Notation for Sybase ASE FLOAT Data

Enabling Visual Styles

When you use Windows Forms dialogs and windows, you may have noticed that they show differently, depending on whether you launched your script from within the ISE editor or from the powershell.exe console. This is because the ISE editor enables visual styles by...

Disable Scientific Notation for Sybase ASE FLOAT Data

Test Local User Account Credentials

Verifying a Local User Account Here is a snippet that verifies a local user account. Simply submit a username and a password. You get back either $true or $false: $username = 'Administrator' $password = 'P@ssw0rd' $computer = $env:COMPUTERNAME Add-Type -AssemblyName...

Disable Scientific Notation for Sybase ASE FLOAT Data

Using RegEx to Filter Files

Get-ChildItem supports basic wildcards, but it does not support the rich feature set of regular expressions. If you combine Get-ChildItem with Where-Object, you can easily add this functionality. Filtering DLL Files by Name Pattern in PowerShell This example lists all...

Disable Scientific Notation for Sybase ASE FLOAT Data

Finding User Account with WMI

WMI represents all kinds of physical and logical entities on your machine. It also has classes that represent user accounts which include both local and domain accounts. Retrieving the Currently Logged-On User This piece of code returns the user account of the...

Disable Scientific Notation for Sybase ASE FLOAT Data

Increase SQL Server Performance Using Multiple Files

By default, SQL Server databases are comprised of two files: the primary data file (or .mdf) and the log file (or .ldf). It is, however, possible to configure SQL Server databases to use additional files – which can be an effective means of increasing SQL Server...