Replacing NTFS Permissions with SDDL Information

Replacing NTFS Permissions with SDDL Information

All PowerShell versions With Get-Acl, you can output the security information from files and folders as plain text in SDDL format (Security Descriptor Definition Language): $FolderToRead = 'C:\folder1' $securityDescriptor = Get-Acl -Path $FolderToRead...

Replacing NTFS Permissions with SDDL Information

Top 4 Startup Parameters DBAs Must Know

Introduction Working on a server is always something DBAs cherish. With every environment that they monitor, they want to know how applications can be optimally run on a specific server. In this constant pursuit of performance tuning, they always find unique ways of...

Replacing NTFS Permissions with SDDL Information

Pinging via IPv4

All PowerShell versions You can use ping.exe just like any other command inside PowerShell scripts. By adding “-4” to the command line, you can force ping to use IPv4 (add “-6” to force IPv6 instead). PS> ping localhost -4 ReTweet this...

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...

Replacing NTFS Permissions with SDDL Information

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...

Replacing NTFS Permissions with SDDL Information

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...

Replacing NTFS Permissions with SDDL Information

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...

Replacing NTFS Permissions with SDDL Information

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):...

Replacing NTFS Permissions with SDDL Information

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...

Replacing NTFS Permissions with SDDL Information

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...

Replacing NTFS Permissions with SDDL Information

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...

Replacing NTFS Permissions with SDDL Information

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...

Replacing NTFS Permissions with SDDL Information

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 =...

Replacing NTFS Permissions with SDDL Information

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...

Replacing NTFS Permissions with SDDL Information

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...

Replacing NTFS Permissions with SDDL Information

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...