Quantcast
Channel: Jose Barreto's Blog
Viewing all 122 articles
Browse latest View live

New version of the Storage Spaces physical disk validation PowerShell script

$
0
0

The Storage Spaces team has just published a new version of the Storage Space disk validation script written in PowerShell.

This script makes sure that the physical disks in a system have everything that is needed by Storage Spaces. That includes checking functional requirements and performance characteristics.

In the same way that we ask you to run the Cluster Validation Wizard before creating a cluster, it is a great idea to always run this script before using a specific set of disks with Storage Spaces.

The changes in the version 2 of the script include:

  • Intelligent parallelized drive profiling dramatically speeds up script execution time. Script will first profile throughput and IOPS of a single drive from each group, then the group in aggregate, and use these numbers to figure out the maximum batch size possible while remaining under Throughput or CPU limitations.
  • Intelligent SSD preconditioning. Script will only pre-condition the SSDs to sufficient time to overwrite the address space twice.
  • Switched to more reliable percentile-based latency measurements, rather than Min/Avg/Max.
  • In addition to the existing relative performance testing and comparisons, there are absolute performance thresholds which drives must meet in order to pass.
  • (currently disabled) MPIO testing for supported configurations will compare Round Robin performance to Fail-over only in order to determine optimal policies for specific drives and firmware versions. Further, the script detects the number of paths to drives through the devcon utility - this can help determine if there is an uneven configuration where a set of drives only has a single path, while other drives have multiple.
  • Drive wear is evaluated.
  • Switched to the new Diskspd version 2 release which brings a number of improvements over SQLIO.
  • Significant improvement to the output report.

Download the script from:


PowerShell Examples: Calculating very small and very large numbers

$
0
0

This blog is part of a series that shows example PowerShell code for those learning the language.

This time we’re using PowerShell to find some very small and very large floating point numbers. The principal here is that if you keep dividing a number by 2, there will be a point where the number is so small that you get zero when you divide it. In a similar fashion, if you keep multiplying a number by 2, there will be a point that the number is so large that it’s considered to be “infinity”.

This example shows details about the differently floating point data types ([single] and [double]) and also shows the use of while loops.

You might want to remove the comment on the “Write-Host $last1” line to show the progression to the final number in each example.

# PowerShell lessons
# Calculating minimum and maximum numbers

cls

# Minimum using the [double] data type

[double] $last1 = 1
[double] $last2 = 0
[double] $last3 = 0
while ($last1 –ne $last2)
{
#    Write-Host $last1
    $last3 = $last2
    $last2 = $last1
    $last1 /= 2
}
Write-Host "The smallest double is $last3. After that, we get $last2"

# Minimum using the [single] data type

[single] $last1 = 1
[single] $last2 = 0
[single] $last3 = 0
while ($last1 –ne $last2)
{
#    Write-Host $last1
    $last3 = $last2
    $last2 = $last1
    $last1 /= 2
}
Write-Host "The smallest single is $last3. After that, we get $last2"

# Maximum using the [double] data type

[double] $last1 = 1
[double] $last2 = 0
[double] $last3 = 0
while ($last1 –ne $last2)
{
#    Write-Host $last1
    $last3 = $last2
    $last2 = $last1
    $last1 *= 2
}
Write-Host "The largest double is $last3. After that, we get $last2"

# Maximum using the [single] data type

[single] $last1 = 1
[single] $last2 = 0
[single] $last3 = 0
while ($last1 –ne $last2)
{
#    Write-Host $last1
    $last3 = $last2
    $last2 = $last1
    $last1 *= 2
}
Write-Host "The largest single is $last3. After that, we get $last2"

#
# Sample output
#
# The smallest double is 4.94065645841247E-324. After that, we get 0
# The smallest single is 1.401298E-45. After that, we get 0
# The largest double is 8.98846567431158E+307. After that, we get Infinity
# The largest single is 1.701412E+38. After that, we get Infinity
#

PowerShell Examples: Calculating Prime Numbers

$
0
0

This blog is part of a series that shows example PowerShell code for those learning the language.

This time we’re using PowerShell to find prime numbers. This is not using any sophisticated method, just checking the remainder for all numbers between 2 and the square root of the number.

This example explores loops and general math operations. There is also an interesting trick with showing multiple numbers per line using the “no new line” option.

#
# Finding Prime Numbers
#

# Primes between 2 and 1000
#

Cls

Write-Host "Calculating prime numbers"
Write-Host ""

$count = 0
2..1000 | foreach {

    $number = $_
    $divisor = [math]::Sqrt($number)
    $prime = $true

    2..$divisor | foreach {
        if ($number % $_ -eq 0) {
            $prime = $false
        }
    }

    If ($prime) {
        Write-Host -NoNewline $number.ToString().PadLeft(4)
        $count++
        If ($count % 10 -eq 0) {
            Write-Host ""
        }
    }

}

Write-Host ""
Write-Host "$count primes between 2 and 1000"
Write-Host ""

$count = 0
1000000..1000999 | foreach {

    $number = $_
    $divisor = [math]::Sqrt($number)
    $prime = $true

    2..$divisor | foreach {
        if ($number % $_ -eq 0) {
            $prime = $false
        }
    }

    If ($prime) {
        Write-Host -NoNewline $number.ToString().PadLeft(8)
        $count++
        If ($count % 5 -eq 0) {
            Write-Host ""
        }
    }

}

Write-Host ""
Write-Host "$count primes between 1000000 and 1000999"
Write-Host ""

 

In case you were wondering what the output would look like, here it is:

 

Calculating prime numbers

   3   5   7  11  13  17  19  23  29  31
  37  41  43  47  53  59  61  67  71  73
  79  83  89  97 101 103 107 109 113 127
131 137 139 149 151 157 163 167 173 179
181 191 193 197 199 211 223 227 229 233
239 241 251 257 263 269 271 277 281 283
293 307 311 313 317 331 337 347 349 353
359 367 373 379 383 389 397 401 409 419
421 431 433 439 443 449 457 461 463 467
479 487 491 499 503 509 521 523 541 547
557 563 569 571 577 587 593 599 601 607
613 617 619 631 641 643 647 653 659 661
673 677 683 691 701 709 719 727 733 739
743 751 757 761 769 773 787 797 809 811
821 823 827 829 839 853 857 859 863 877
881 883 887 907 911 919 929 937 941 947
953 967 971 977 983 991 997
167 primes between 2 and 1000

1000003 1000033 1000037 1000039 1000081
1000099 1000117 1000121 1000133 1000151
1000159 1000171 1000183 1000187 1000193
1000199 1000211 1000213 1000231 1000249
1000253 1000273 1000289 1000291 1000303
1000313 1000333 1000357 1000367 1000381
1000393 1000397 1000403 1000409 1000423
1000427 1000429 1000453 1000457 1000507
1000537 1000541 1000547 1000577 1000579
1000589 1000609 1000619 1000621 1000639
1000651 1000667 1000669 1000679 1000691
1000697 1000721 1000723 1000763 1000777
1000793 1000829 1000847 1000849 1000859
1000861 1000889 1000907 1000919 1000921
1000931 1000969 1000973 1000981 1000999
75 primes between 1000000 and 1000999

PowerShell Examples: Calculating the value of Pi

$
0
0

This blog is part of a series that shows example PowerShell code for those learning the language.

This time we’re using PowerShell to find the value of Pi. This is done using one of the many methods available, using a division between n! (factorial) and (n*2+1)! (factorial of odd numbers).

This example explores loops and general math operations, including operators like +=, *= and ++. We also using the Math function to calculate Pi and compare our results.

 

#
# Calculating Pi without using [math]::Pi
#

[double] $halfpi=1
[int] $num=1
[double] $factorial=1
[double] $oddfactorial=1
[double] $pi = 1
[double] $previouspi = 0

while ($previouspi -ne $pi) {
    $previouspi = $pi
    $factorial *= $num
    $oddfactorial *= (($num*2)+1)
    $halfpi += $factorial / $oddfactorial
    $pi = 2 * $halfpi
    Write-Output "Step $num - Pi is $pi"
    $num++
}

$num--
Write-Output ""
Write-Output "Calculated Pi as $pi after $num iterations."
$SystemPi = [Math]::Pi
Write-Output "The system Pi is $SystemPi (returned by [Math]::Pi)."
[double] $Difference = $SystemPi - $pi
Write-Output "Difference between the two is $Difference"

#
# Sample output:
#
# Calculated Pi as 3.14159265358979 after 50 iterations.
# The system Pi is 3.14159265358979 (returned by [Math]::Pi).
# Difference between the two is 8.88178419700125E-16
#

PowerShell Examples: Generating Random Names

$
0
0

This blog is part of a series that shows example PowerShell code for those learning the language.

This time we’re using PowerShell to generate random full names using common first names and common last names. It basically combines a random first name with a random letter for middle initial and a random last name.

This example explores the use of loops, random numbers, string functions (split, padright) and conversion from [int] to [char].

 

#
# Creating common names
#
# Using the top first names published by the SSA at
http://www.ssa.gov/OACT/babynames/
# And the top last names from http://en.wikipedia.org/wiki/List_of_most_common_surnames_in_North_America
#

$first = "Noah Sophia Liam Emma Jacob Olivia Mason Isabella William Ava Ethan Mia Michael Emily Alexander Abigail Jayden Madison Daniel Elizabeth".Split(" ")
$last = "Smith Johnson Williams Brown Jones Miller Davis Garcia Rodriguez Wilson Martinez Anderson Taylor Thomas Hernandez Moore Martin Jackson Thompson White".Split(" ")

Clear-Host
Write-Host "Random full name generator"
Write-Host

1..20 | foreach {
    $f = $first[ (Get-Random $first.count ) ]
    $m = [char] (65 + (Get-Random 26) )
    $l = $last[ (Get-Random $last.count) ]
    $full = $f+" "+$m+" "+$l
    Write-Host -NoNewline $full.PadRight(25)
    If ($_ % 2 -eq 0) {
        Write-Host ""
    }
}
 

#
# Sample output
#
# Random full name generator
#
# Emily B Miller           Olivia N Hernandez      
# Mia I Jones              Olivia W Miller         
# Noah M Williams          Daniel V Thomas         
# William Y Martin         Elizabeth A Thompson    
# Mia A Martinez           Abigail G Johnson       
# Ethan I Williams         Noah L Taylor           
# Madison K Rodriguez      Michael Z Smith         
# Mason B Thompson         William I Thomas        
# Mia U Smith              Emily R Taylor          
# Daniel Q Wilson          Elizabeth R Taylor      
#

PowerShell Examples: Counting words in a text file

$
0
0

This blog is part of a series that shows example PowerShell code for those learning the language.

This time we’re using PowerShell to count lines, count words, find the largest word and find the most frequently used words in a text file. To make it interesting, we’re using a plain text version of “Alice in Wonderland” downloaded from the Project Guttenberg site.

This example explores string manipulation and the use of hash tables. It also shows the use of Write-Progress.

 

#
# Counting words in a text file
# Uses the text from Alice in Wonderland
#
from http://www.gutenberg.org/ebooks/11.txt.utf-8
#

Clear-Host
$FileName = ".\Alice.TXT"
Write-Host "Reading file $FileName..."
$File = Get-Content $FileName
$TotalLines = $File.Count
Write-Host "$TotalLines lines read from the file."

$SearchWord = "WONDERLAND"
$Found = 0
$WordCount = 0
$Longest = ""
$Dictionary = @{}
$LineCount = 0

$File | foreach {
    $Line = $_
    $LineCount++
    Write-Progress -Activity "Processing words..." -PercentComplete ($LineCount*100/$TotalLines)
    $Line.Split(" .,:;?!/()[]{}-```"") | foreach {
        $Word = $_.ToUpper()
        If ($Word[0] -ge 'A' -and $Word[0] -le "Z") {
            $WordCount++
            If ($Word.Contains($SearchWord)) { $Found++ }
            If ($Word.Length -gt $Longest.Length) { $Longest = $Word }
            If ($Dictionary.ContainsKey($Word)) {
                $Dictionary.$Word++
            } else {
                $Dictionary.Add($Word, 1)
            }
        }
    }
}

Write-Progress -Activity "Processing words..." -Completed
$DictWords = $Dictionary.Count
Write-Host "There were $WordCount total words in the text"
Write-Host "There were $DictWords distinct words in the text"
Write-Host "The word $SearchWord was found $Found times."
Write-Host "The longest word was $Longest"
Write-Host
Write-Host "Most used words with more than 4 letters:"

$Dictionary.GetEnumerator() | ? { $_.Name.Length -gt 4 } |
Sort Value -Descending | Select -First 20

 

In case you were wondering what the output would look like, here it is:

 

Reading file .\Alice.TXT...
3339 lines read from the file.
There were 25599 total words in the text
There were 2616 distinct words in the text
The word WONDERLAND was found 3 times.
The longest word was DISAPPOINTMENT

Most used words with more than 4 letters:

Name                   Value
----                   -----
ALICE                  385
LITTLE                 128
ABOUT                  94 
AGAIN                  83 
HERSELF                83  
WOULD                  78  
COULD                  77  
THOUGHT                74  
THERE                  71  
QUEEN                  68  
BEGAN                  58  
TURTLE                 57  
QUITE                  55  
HATTER                 55 
DON'T                  55 
GRYPHON                55 
THINK                  53 
THEIR                  51  
FIRST                  50 
THING                  49  

PowerShell Examples: Guess the number

$
0
0

This blog is part of a series that shows example PowerShell code for those learning the language.

This time we’re using PowerShell create a simple game where you need to guess a number.

This example explores basic loops, logical operations (like –ne, –ge, –lt) and entering data with Read-Host.

 

#
# Guess the number
#

[int] $Number = (Get-Random 100) + 1
[int] $Guess = 0

Write-Host "I'm thinking of a number between 1 and 100."

While ($Number -ne $Guess) {

    Write-Host -NoNewline "What is the number? "
    $Guess = [int] (Read-Host)

    If ($Guess -gt $Number) { Write-Host "$Guess is too high." }
    If ($Guess -lt $Number) { Write-Host "$Guess is too low." }   

}
Write-Host "Correct! $Number is the number I was thinking!"

 

In case you were wondering what the output would look like, here it is:

 

I'm thinking of a number between 1 and 100.
What is the number? 50
50 is too high.
What is the number? 25
25 is too high.
What is the number? 12
12 is too low.
What is the number? 19
19 is too high.
What is the number? 15
15 is too high.
What is the number? 13
Correct! 13 is the number I was thinking!

PowerShell Examples: Adventure House Game

$
0
0

This blog is part of a series that shows example PowerShell code for those learning the language.

This time we’re using PowerShell create a text adventure game that requires to find your way out of a house using simple commands. There is a locked door and you need to find a key.

This example explores the use of arrays (an array of arrays, actually), string manipulation and the switch statement.

 

#
# Adventure House Game v3 # By Jose Barreto
# Written as a PowerShell Example in March 2015
#

[Array] $Rooms = (
#    Name                 Description                           N  S  E  W   U   D
(00,"Exit!",             "Exit!"                               ,99,99,99,01,99,99),
(01,"Entrance Hall",     "entrance hall. The door is locked"   ,10,02,99,99,99,99),
(02,"Downstairs Hall",   "hall at the bottom of the stairs"    ,01,04,03,99,11,99),
(03,"Guest Bathroom",    "small guest bathroom downstaris"     ,99,99,05,02,99,99),
(04,"Living Room",       "living room on the southeast side"   ,02,99,99,05,99,99),
(05,"Family Room",       "family room with a large TV"         ,06,99,02,99,99,99),
(06,"Nook",              "nook with a small dining table"      ,07,05,99,24,99,99),
(07,"Kitchen",           "kitchen with a large granite counter",08,06,99,99,99,99),
(08,"Trash Hall",        "small hall with two large trash cans",99,07,10,09,99,99),
(09,"Garage",            "garage, the big door is closed"      ,99,99,08,99,99,99),
(10,"Dining Room",       "dining room on the northeast side"   ,99,01,99,08,99,99),
(11,"Upstairs Hall",     "hall at the top of the stairs"       ,99,12,16,13,99,02),
(12,"Upper East Hall",   "hall with two tables and computers"  ,11,15,99,99,99,99),
(13,"Upper North Hall",  "hall with a large closet"            ,18,14,11,17,99,99),
(14,"Upper West Hall",   "hall with a small closet"            ,13,23,99,22,99,99),
(15,"Guest Room",        "guest room with a queen size bed"    ,12,99,99,99,99,99),
(16,"Laundry",           "laundry room with a washer and dryer",99,99,99,11,99,99),
(17,"Main Bathroom",     "main bathroom with a bathtub"        ,99,99,13,99,99,99),
(18,"Master Bedroom",    "master bedroom with a king size bed" ,21,13,19,99,99,99),
(19,"Master Closet",     "long and narrow walk-in closet"      ,99,99,99,18,20,99),
(20,"Attic",             "attic, it is dark in here"           ,99,99,99,99,99,19),
(21,"Master BathRoom",   "master bedroom with a shower and tub",99,18,99,99,99,99),
(22,"Children's Room",   "children's room with twin beds"      ,99,99,14,99,99,99),
(23,"Entertainment Room","play room with games and toys"       ,14,99,99,99,99,99),
(24,"Patio",             "wooden patio. A key on the floor"    ,99,99,06,99,99,99)

[Array] $Inventory = (
# Name/Loc  Description/Action text
("BREAD", "A small loaf of bread. Not quite a lunch, too big for a snack.",
  00,     "It's too big for a snack. Maybe later, for lunch."),
("BUGLE", "You were never very good with instruments.",
  00,     "You try to no avail to produce something that could constitute music."),
("APPLE", "A nice, red fruit that looks rather apetizing.",
  20,     "Tastes just as good as it looked."),
("KEY",   "A shiny, aesthetically pleasing key. Must open something.",
  24,     "The key fits perfectly and the door unlocked with some effort."),
("WAND",  "A small wooden wand.",
  17,     "You wave the wand and the room fades for a second.")
)

Function Get-InventoryIndex([String] $Name) {
$Found = 99
0..($Inventory.Count-1) | % { If ($Inventory[$_][0] -eq $Name) { $Found = $_ } }
Return $Found
}

Function Get-InventoryCount([int] $InRoom) {
$Found = 0
0..($Inventory.Count-1) | % { If ($Inventory[$_][2] -eq $InRoom) { $Found++ } }
Return $Found
}

Function Get-InventoryItems([int] $InRoom) {
$Items = ""
0..($Inventory.Count-1) | % { If ($Inventory[$_][2] -eq $InRoom) { $Items += $Inventory[$_][0]+" " } }
If ($Items -eq "") {$Items = "None"}
Return $Items
}

[Int] $Room = 20
[Int] $EHall = 01
[String] $Message = "Find the way out of this house."
[Int] $Health = 100

While ($Room -ne 0) {
    $Name  = $Rooms[$Room][1]
    $Desc  = $Rooms[$Room][2]
    $North = $Rooms[$Room][3]
    $South = $Rooms[$Room][4]
    $East  = $Rooms[$Room][5]
    $West  = $Rooms[$Room][6]
    $Up    = $Rooms[$Room][7]
    $Down  = $Rooms[$Room][8] 

    $Available = "[Q]uit"
    If ($North -ne 99) { $Available += ", [N]orth" }
    If ($South -ne 99) { $Available += ", [S]outh" }
    If ($East  -ne 99) { $Available += ", [E]ast" }
    If ($West  -ne 99) { $Available += ", [W]est" }
    If ($Up    -ne 99) { $Available += ", [U]p" }
    If ($Down  -ne 99) { $Available += ", [D]own" }
    If (Get-InventoryCount($Room) -gt 0) { $Available+= ", [P]ick " }
    If (Get-InventoryCount(0) -gt 0 ) { $Available+= ", [R]elease, [I]nspect, [A]pply " }

    Clear-Host
    Write-Host $Message
    $Message="" 

    Write-Host
    Write-Host -ForegroundColor Yellow $Name
    Write-Host "You are at the $Desc"
    $Items = Get-InventoryItems($Room)
    Write-Host "Items in this room : $Items"

    Write-Host
    Write-Host "You are feeling $Health%"
    $Items = Get-InventoryItems(0)
    Write-Host "Your have : $Items"
    Write-Host

    Write-Host -ForegroundColor Green "Commands : $Available ? " -NoNewline
    $Cmd = Read-Host
    $Cmd = $Cmd.ToUpper()
    $Action = $Cmd[0]
    $Item = $Cmd.Split(" ")[1] 

    Switch ($Action) {
    "N" { If ($North -ne 99) { $Room = $North }
          else {$Message = "You can't go north from here. " }
        }

    "S" { If ($South -ne 99) { $Room = $South }
          else {$Message = "South? You can't go that direction now. " }
        }

    "E" { If ($East  -ne 99) { $Room = $East  }
          else {$Message = "East is not an option here." }
        }

    "W" { If ($West  -ne 99) { $Room = $West  }
          else {$Message = "No can do. There is a wall there." }
        }

    "U" { If ($Up    -ne 99) { $Room = $Up    }
          else {$Message = "Do you see stairs anywhere? I don't." }
        }

    "D" { If ($Down  -ne 99) { $Room = $Down  }
          else {$Message = "I can't break the floor." }
        }

    "I" { if ($item -eq "" -or $item -eq $null) { $Message = "Inspect what?" }
          else {
              $ItemIndex = Get-InventoryIndex($Item)
              if ($ItemIndex -eq 99) { $Message = "I have no clue what '$Item' is." }
              else {
                  $ItemRoom =  $Inventory[$ItemIndex][2]
                  If ($ItemRoom -eq $Room) { $Message = "I can't see well. Maybe if I pick it up." }
                  elseIf ($ItemRoom -eq 00) { $Message = $Inventory[$ItemIndex][1] }
                  else { $Message = "There is no '$Item' here." }
              } #end if $ItemIndex -eq 99
           } #end $item -eq ""
        } #end "I"

    "P" { if ($item -eq "" -or $item -eq $null) { $Message = "Pick what?" }
          else {
              $ItemIndex = Get-InventoryIndex($Item)
              if ($ItemIndex -eq 99) { $Message = "I have no clue what '$Item' is." }
              else {
                  $ItemRoom =  $Inventory[$ItemIndex][2]
                  if ($ItemRoom -eq 00) { $Message = "You already have the '$Item'." }
                  elseif ($ItemRoom -ne $Room) { $Message = "There is no '$Item' here." }
                  else {
                      $Inventory[$ItemIndex][2] = 0
                      $Message = "You picked the '$Item'."
                  }
              } #end if $ItemIndex -eq 99
           } #end $item -eq ""
        } #end "I"

    "R" { if ($item -eq "" -or $item -eq $null) { $Message = "Release what?" }
          else {
              $ItemIndex = Get-InventoryIndex($Item)
              if ($ItemIndex -eq 99) { $Message = "I have no clue what '$Item' is." }
              else {
                  $ItemRoom =  $Inventory[$ItemIndex][2]
                  if ($ItemRoom -ne 00) { $Message = "You don't have the '$Item'." }
                  else {
                      $Inventory[$ItemIndex][2] = $Room
                      $Message = "You dropped the '$Item'."
                  }
              } #end if $ItemIndex -eq 99
           } #end $item -eq ""
        } #end "R"

    "A" { if ($item -eq "" -or $item -eq $null) { $Message = "Apply what?" }
          else {
              $ItemIndex = Get-InventoryIndex($Item)
              if ($ItemIndex -eq 99) { $Message = "I have no clue what '$Item' is." }
              else {
                  $ItemRoom =  $Inventory[$ItemIndex][2]
                  if ($ItemRoom -ne 00) { $Message = "You don't have the '$Item'." }
                  else {
                     $Message = $Inventory[$ItemIndex][3]
                     Switch ($Item) {
                     "KEY"   { if ($Room -ne $EHall) { $Message = "The key doesn't fit anywhere here." }
                               elseif ($Rooms[$EHall][5] -eq 99 ) {
                                   $Rooms[$EHall][2] = "hall by the entrance. The key unlocked the door."
                                   $Rooms[$EHall][5] = 0 }
                               else { $Message = "You already unlocked the door a moment ago." }
                             } #end key
                     "WAND"  { $Room = (Get-Random ($Rooms.Count -1)) + 1 }
                     "BREAD" { If ($Health -le 30 ) {
                                   $Health += 50
                                   $Inventory[$ItemIndex][2] = 99
                                   $Message = "I did not realize how hungry I was..."
                               }
                             }
                     "APPLE" { $Health += 50
                               If ($Health -gt 100) {$Health = 100}
                               $Inventory[$ItemIndex][2] = 99
                             }
                     } #end switch $item
                  } # if $ItemRoom -ne 00
              } #end if $ItemRoom -eq 99
           } #end $item -eq ""
        } #end "R"

    "Q" { $Room = 0 }

    default { $Message = "I do not know how to " + $Cmd }

     } #end switch $Action

     $Health -= 2
     If ($Health -le 0) {
        $Room = 0
        $Action = "Q"
        Write-Host "You died."
    }

} #end while

if ($Action -ne "Q") { Write-Host "You found the way out. Congratulations!" }
                else { Write-Host "Better luck next time..." }


PowerShell Examples – Random words and their popularity via Bing

$
0
0

This blog is part of a series that shows example PowerShell code for those learning the language.

This time we’re using PowerShell to generate random words and check if they are popular by using a Bing search. The words are color-coded as white (not found on the web), green (between 1 and 1,000 hits on the web), yellow (between 1,000 and 1,000,000 hits) and red (more than 1,000,000 hits). This could be useful if you need to create a username on a popular website and everything you can think of is already taken :-).

This example explores using the Internet Explorer objects and searching through web pages by ID, along with more common items like arrays, string manipulation and functions.

 

#
# Random words and their popularity with Bing
#

#
# Defines array with common vowels, consonants and endings
#

[array] $Vowels = "a;a;a;a;e;e;e;e;i;i;i;o;o;o;u;u;y" -split ";"
[array] $Consonants = "b;b;br;c;c;c;ch;cr;d;f;g;h;j;k;l;m;m;m;n;n;p;p;ph;qu;r;r;r;s;s;s;sh;t;tr;v;w;x;z" -split ";"
[array] $Endings = "r;r;s;r;l;n;n;n;c;c;t;p" -split ";"

#
# Functions for random vowels, consonants, endings and words
#

function Get-RandomVowel
{ return $Vowels[(Get-Random($Vowels.Length))] }

function Get-RandomConsonant
{ return $Consonants[(Get-Random($Consonants.Length))] }

function Get-RandomEnding
{ return $Endings[(Get-Random($Endings.Length))] }

function Get-RandomSyllable ([int32] $PercentConsonants, [int32] $PercentEndings)

   [string] $Syllable = ""
   if ((Get-Random(100)) -le $PercentConsonants)
   { $Syllable+= Get-RandomConsonant }
   $Syllable+= Get-RandomVowel
   if ((Get-Random(100)) -le $PercentEndings)
   { $Syllable+= Get-RandomEnding }
   return $Syllable
}

function Get-RandomWord ([int32] $MinSyllables, [int32] $MaxSyllables)

   [string] $Word = ""
   [int32] $Syllables = ($MinSyllables) + (Get-Random(($MaxSyllables - $MinSyllables + 1)))
   for ([int32] $Count=1; $Count -le $Syllables; $Count++)
   { $Word += Get-RandomSyllable 70 20 } <# Consonant 70% of the time, Ending 20% #>
   return $Word
}

#
# Function to see how many pages Bing finds for a given term
#

Function Get-BingCount([string] $Term) {

    # Navigate to the Bing page to query the $term
    $ie.Navigate("
http://bing.com/search?q=%2B"+$term);

    # Wait for the page to load
    $timeout = 0
    while ($ie.Busy) {
        # Write-Host "Waiting for Bing page for $term to load"
        Start-Sleep -Milliseconds 100
        $timeout++
        If ($timeout  -gt 100) {
            return "L-Error"
        }
    }    

    # Wait for the document to be ready
    $timeout = 0
    $element1 = $ie.Document.IHTMLDocument3_getElementById("b_tween").innertext
    $element2 = $ie.Document.IHTMLDocument3_getElementById("b_content").innertext
    While ($element1 -eq $null -and $element2 -eq $null) {
        # Write-Host "Waiting for Bing document for $term to be ready"
        Start-Sleep -Milliseconds 100
        $timeout++
        If ($timeout  -gt 100) {
            return "D-Error"
        }
        $element1 = $ie.Document.IHTMLDocument3_getElementById("b_tween").innertext
        $element2 = $ie.Document.IHTMLDocument3_getElementById("b_content").innertext
    }

    # Get the count of pages
    If ($element1 -ne $null) { $result = $element1.split(" ")[0] }
                       else  { $result = "0" }
    # Return the count
    return $result
}

#
# Main code
#

# Create Internet Explorer object
$ie = New-Object -ComObject "InternetExplorer.Application"     

# Show initial message
Write-Host
Write-Host "Here are 20 random words and their popularity"
Write-Host

1..20 | % {
    # Get a random word
    $word = Get-RandomWord 2 5

    # Check the popularity with Bing
    $count = ([string] (Get-BingCount $word)).Padleft(12)
    $countint = [int] $count

    # Select Color based on popularity.
    if     ($countint -eq 0)       { $color = "white"  }
    elseif ($countint -lt 1000)    { $color = "green"  }
    elseif ($countint -lt 1000000) { $color = "yellow" }
    else                           { $color = "red"    } 

    # Write the info with the right color
    Write-Host "$count --> $word" -ForegroundColor $color
}

# Quit Internet Explorer
$ie.quit();

 

In case you were wondering what the output would look like, here is a sample:

image

PowerShell Examples: Using Bing to measure the popularity of cmdlets in a specific PowerShell module

$
0
0

This blog is part of a series that shows example PowerShell code for those learning the language.

This time we’re using PowerShell to find out which PowerShell cmdlet in a specific module is the most popular. To do this, we’re using a Bing search and producing a list with the name and number of web pages found for each one. This is returned as an object, so you can pipe the output to sort or filter. The name of the module is hard coded to “SmbShare”, but you can replace it with any valid module name. You could also make a parameter.

This example explores using the Web client in the .NET System.Web assembly, searching through the resulting web page using string functions, showing cmdlet progress and also a trick to create an object on the fly. It also shows more common items like arrays and functions.

 

#
# Popularity (via Bing) of the PowerShell cmdlets in a module
#

#
# Function to see how many pages Bing finds for a given term
#

# Adds assembly to support URL encoding and the web client

Add-Type -Assembly System.Web
$WebClient = New-Object system.Net.WebClient

Function Get-BingCount([string] $Term) {

    # Add plus and quotes, encodes for URL
    $Term = '+"' + $Term + '"'
    $Term = [System.Web.HttpUtility]::UrlEncode($Term)

    # Load the page as a string
    $URL = "http://www.bing.com/search?q=" + $Term
    $Page = $WebClient.DownloadString($URL)

    # searches for the string before the number of hits on the page
    $String1 = '<span class="sb_count">'
    $Index1 = $Page.IndexOf($String1)

    # if found the right string, finds the exact end of the number
    If ($Index1 -ne -1) {
        $Index1 += $String1.Length
        $Index2 = $Page.IndexOf(" ", $Index1)
        $result = $Page.Substring($Index1, $Index2 - $index1)
    } else { $result = "0" }

    # Return the count
    return $result
}

#
# Main code
#

$CmdletList = Get-Command -Module SmbShare | Select Name
$CmdletCount = $CmdletList.Count -1

0..$CmdletCount | % {

    # Tracks progress
    Write-Progress -Activity "Checking cmdlet popularity" -PercentComplete ($_ * 100 / $CmdletCount)

    # Check the popularity with Bing
    $cmdlet = $CmdletList[$_].Name
    $count = [int] (Get-BingCount $cmdlet)

    # Format as a row, output it
    $Row = "" | Select CmdletName, BingCount
    $Row.CmdletName  = $cmdlet
    $Row.BingCount = $count
    $Row
}

Write-Progress -Activity "Checking cmdlet popularity" -Completed

# Releases resources used by the web client
$WebClient.Dispose()

 

In case you were wondering what the output would look like, here is a sample:

CmdletPopularity

Windows PowerShell equivalents for common networking commands (IPCONFIG, PING, NSLOOKUP)

$
0
0

Network troubleshooting is part any System Administrator’s life. Maybe you need to check the IP address of a machine or test if its networking connection is working. Maybe you need to see if DNS is properly configured or check the latency between two hosts.

If you have been in this field long enough, you probably have a few favorite commands that you learned years ago and use on a regular basis, like IPCONFIG or PING.

There are literally hundreds of networking-related PowerShell cmdlets in Windows these days. Just try out this command on your machine: Get-Command -Module Net* | Group Module

But more important than knowing every one of them, is to know the most useful cmdlets that have the potential to replace those old commands that you can’t live without.

And it’s when you combine the many networking cmdlets in ways that only PowerShell can do that you’ll find amazing new troubleshooting abilities…

 

IPCONFIG

Description: This command has many options, but the most common usage is just to show the IP address, subnet mask and default gateway for each network adapter in a machine.

PowerShell: Get-NetIPConfiguration or Get-NetIPAddress

Sample command lines:

  • Get-NetIPConfiguration
  • Get-NetIPAddress | Sort InterfaceIndex | FT InterfaceIndex, InterfaceAlias, AddressFamily, IPAddress, PrefixLength -Autosize
  • Get-NetIPAddress | ? AddressFamily -eq IPv4 | FT –AutoSize
  • Get-NetAdapter Wi-Fi | Get-NetIPAddress | FT -AutoSize

Sample output:

PS C:\> Get-NetIPConfiguration

InterfaceAlias       : Wi-Fi
InterfaceIndex       : 3
InterfaceDescription : Dell Wireless 1703 802.11b|g|n (2.4GHz)
NetProfile.Name      : HomeWifi
IPv6Address          : fded:b22c:44c4:1:88f2:9970:4082:4118
IPv4Address          : 192.168.1.2
IPv6DefaultGateway   :
IPv4DefaultGateway   : 192.168.1.1
DNSServer            : 192.168.1.1

InterfaceAlias       : Bluetooth Network Connection
InterfaceIndex       : 6
InterfaceDescription : Bluetooth Device (Personal Area Network)
NetAdapter.Status    : Disconnected

InterfaceAlias       : Ethernet
InterfaceIndex       : 4
InterfaceDescription : Realtek PCIe GBE Family Controller
NetAdapter.Status    : Disconnected

PS C:\> Get-NetIPAddress | Sort InterfaceIndex | FT InterfaceIndex, InterfaceAlias, AddressFamily, IPAddress, PrefixLength –Autosize

InterfaceIndex InterfaceAlias                                AddressFamily IPAddress                            PrefixLength
-------------- --------------                                ------------- ---------                            -------
             1 Loopback Pseudo-Interface 1                            IPv6 ::1                                      128
             1 Loopback Pseudo-Interface 1                            IPv4 127.0.0.1                                  8
             3 Wi-Fi                                                  IPv6 fe80::88f2:9970:4082:4118%3               64
             3 Wi-Fi                                                  IPv6 fded:b22c:44c4:1:f188:1e45:58e3:9242     128
             3 Wi-Fi                                                  IPv6 fded:b22c:44c4:1:88f2:9970:4082:4118      64
             3 Wi-Fi                                                  IPv4 192.168.1.2                               24
             4 Ethernet                                               IPv6 fe80::ce6:97c9:ae58:b393%4                64
             4 Ethernet                                               IPv4 169.254.179.147                           16
             6 Bluetooth Network Connection                           IPv6 fe80::2884:6750:b46b:cec4%6               64
             6 Bluetooth Network Connection                           IPv4 169.254.206.196                           16
             7 Local Area Connection* 3                               IPv6 fe80::f11f:1051:2f3d:882%7                64
             7 Local Area Connection* 3                               IPv4 169.254.8.130                             16
             8 Teredo Tunneling Pseudo-Interface                      IPv6 2001:0:5ef5:79fd:1091:f90:e7e9:62f0       64
             8 Teredo Tunneling Pseudo-Interface                      IPv6 fe80::1091:f90:e7e9:62f0%8                64
             9 isatap.{024820F0-C990-475F-890B-B42EA24003F1}          IPv6 fe80::5efe:192.168.1.2%9                 128

PS C:\> Get-NetIPAddress | ? AddressFamily -eq IPv4 | FT –AutoSize

ifIndex IPAddress       PrefixLength PrefixOrigin SuffixOrigin AddressState PolicyStore
------- ---------       ------------ ------------ ------------ ------------ -----------
7       169.254.8.130             16 WellKnown    Link         Tentative    ActiveStore
6       169.254.206.196           16 WellKnown    Link         Tentative    ActiveStore
3       192.168.1.2               24 Dhcp         Dhcp         Preferred    ActiveStore
1       127.0.0.1                  8 WellKnown    WellKnown    Preferred    ActiveStore
4       169.254.179.147           16 WellKnown    Link         Tentative    ActiveStore

PS C:\> Get-NetAdapter Wi-Fi | Get-NetIPAddress | FT -AutoSize

ifIndex IPAddress                            PrefixLength PrefixOrigin        SuffixOrigin AddressState PolicyStore
------- ---------                            ------------ ------------        ------------ ------------ -----------
3       fe80::88f2:9970:4082:4118%3                    64 WellKnown           Link         Preferred    ActiveStore
3       fded:b22c:44c4:1:f188:1e45:58e3:9242          128 RouterAdvertisement Random       Preferred    ActiveStore
3       fded:b22c:44c4:1:88f2:9970:4082:4118           64 RouterAdvertisement Link         Preferred    ActiveStore
3       192.168.1.2                                    24 Dhcp                Dhcp         Preferred    ActiveStore

 

PING

Description: Checks connectivity to a specific host. Commonly used to check for liveliness, but also used to measure network latency.

PowerShell: Test-NetConnection

Sample command lines:

  • Test-NetConnection www.microsoft.com
  • Test-NetConnection -ComputerName www.microsoft.com -InformationLevel Detailed
  • Test-NetConnection -ComputerName www.microsoft.com | Select -ExpandProperty PingReplyDetails | FT Address, Status, RoundTripTime
  • 1..10 | % { Test-NetConnection -ComputerName www.microsoft.com -RemotePort 80 } | FT -AutoSize

Sample output

PS C:\> Test-NetConnection www.microsoft.com

ComputerName           : www.microsoft.com
RemoteAddress          : 104.66.197.237
InterfaceAlias         : Wi-Fi
SourceAddress          : 192.168.1.2
PingSucceeded          : True
PingReplyDetails (RTT) : 22 ms

PS C:\> Test-NetConnection -ComputerName www.microsoft.com -InformationLevel Detailed

ComputerName             : www.microsoft.com
RemoteAddress            : 104.66.197.237
AllNameResolutionResults : 104.66.197.237
                           2600:1409:a:396::2768
                           2600:1409:a:39b::2768
InterfaceAlias           : Wi-Fi
SourceAddress            : 192.168.1.2
NetRoute (NextHop)       : 192.168.1.1
PingSucceeded            : True
PingReplyDetails (RTT)   : 14 ms

PS C:\> Test-NetConnection -ComputerName www.microsoft.com | Select -ExpandProperty PingReplyDetails | FT Address, Status, RoundTripTime -Autosize

Address         Status RoundtripTime
-------         ------ -------------
104.66.197.237 Success            22

PS C:\> 1..10 | % { Test-NetConnection -ComputerName www.microsoft.com -RemotePort 80 } | FT -AutoSize

ComputerName      RemotePort RemoteAddress  PingSucceeded PingReplyDetails (RTT) TcpTestSucceeded
------------      ---------- -------------  ------------- ---------------------- ----------------
www.microsoft.com 80         104.66.197.237 True          17 ms                  True
www.microsoft.com 80         104.66.197.237 True          16 ms                  True
www.microsoft.com 80         104.66.197.237 True          15 ms                  True
www.microsoft.com 80         104.66.197.237 True          18 ms                  True
www.microsoft.com 80         104.66.197.237 True          20 ms                  True
www.microsoft.com 80         104.66.197.237 True          20 ms                  True
www.microsoft.com 80         104.66.197.237 True          20 ms                  True
www.microsoft.com 80         104.66.197.237 True          20 ms                  True
www.microsoft.com 80         104.66.197.237 True          15 ms                  True
www.microsoft.com 80         104.66.197.237 True          13 ms                  True

 

NSLOOKUP

Description: Name server lookup. Mostly used to find the IP address for a given DNS name (or vice-versa). Has many, many options.

PowerShell: Resolve-DnsName

Sample command lines:

  • Resolve-DnsName www.microsoft.com
  • Resolve-DnsName microsoft.com -type SOA
  • Resolve-DnsName microsoft.com -Server 8.8.8.8 –Type A

Sample output

PS C:\> Resolve-DnsName www.microsoft.com

Name                           Type   TTL   Section    NameHost
----                           ----   ---   -------    --------
www.microsoft.com              CNAME  6     Answer     toggle.www.ms.akadns.net
toggle.www.ms.akadns.net       CNAME  6     Answer     www.microsoft.com-c.edgekey.net
www.microsoft.com-c.edgekey.ne CNAME  6     Answer     www.microsoft.com-c.edgekey.net.globalredir.akadns.net
t
www.microsoft.com-c.edgekey.ne CNAME  6     Answer     e10088.dspb.akamaiedge.net
t.globalredir.akadns.net

Name       : e10088.dspb.akamaiedge.net
QueryType  : AAAA
TTL        : 6
Section    : Answer
IP6Address : 2600:1409:a:39b::2768

Name       : e10088.dspb.akamaiedge.net
QueryType  : AAAA
TTL        : 6
Section    : Answer
IP6Address : 2600:1409:a:396::2768

Name       : e10088.dspb.akamaiedge.net
QueryType  : A
TTL        : 6
Section    : Answer
IP4Address : 104.66.197.237

PS C:\> Resolve-DnsName microsoft.com -type SOA

Name                        Type TTL   Section    PrimaryServer               NameAdministrator           SerialNumber
----                        ---- ---   -------    -------------               -----------------           ------------
microsoft.com               SOA  2976  Answer     ns1.msft.net                msnhst.microsoft.com        2015041801

PS C:\> Resolve-DnsName microsoft.com -Server 8.8.8.8 –Type A

Name                                           Type   TTL   Section    IPAddress
----                                           ----   ---   -------    ---------
microsoft.com                                  A      1244  Answer     134.170.188.221
microsoft.com                                  A      1244  Answer     134.170.185.46

 

ROUTE

Description: Shows the IP routes in a given system (also used to add and delete routes)

PowerShell: Get-NetRoute (also New-NetRoute and Remove-NetRoute)

Sample command lines:

  • Get-NetRoute -Protocol Local -DestinationPrefix 192.168*
  • Get-NetAdapter Wi-Fi | Get-NetRoute

Sample output:

PS C:\WINDOWS\system32> Get-NetRoute -Protocol Local -DestinationPrefix 192.168*

ifIndex DestinationPrefix NextHop RouteMetric PolicyStore
------- ----------------- ------- ----------- -----------
2       192.168.1.255/32  0.0.0.0         256 ActiveStore
2       192.168.1.5/32    0.0.0.0         256 ActiveStore
2       192.168.1.0/24    0.0.0.0         256 ActiveStore

PS C:\WINDOWS\system32> Get-NetAdapter Wi-Fi | Get-NetRoute

ifIndex DestinationPrefix                        NextHop     RouteMetric PolicyStore
------- -----------------                        -------     ----------- -----------
2       255.255.255.255/32                       0.0.0.0             256 ActiveStore
2       224.0.0.0/4                              0.0.0.0             256 ActiveStore
2       192.168.1.255/32                         0.0.0.0             256 ActiveStore
2       192.168.1.5/32                           0.0.0.0             256 ActiveStore
2       192.168.1.0/24                           0.0.0.0             256 ActiveStore
2       0.0.0.0/0                                192.168.1.1           0 ActiveStore
2       ff00::/8                                 ::                  256 ActiveStore
2       fe80::d1b9:9258:1fa:33e9/128             ::                  256 ActiveStore
2       fe80::/64                                ::                  256 ActiveStore
2       fded:b22c:44c4:1:d1b9:9258:1fa:33e9/128  ::                  256 ActiveStore
2       fded:b22c:44c4:1:c025:aa72:9331:442/128  ::                  256 ActiveStore
2       fded:b22c:44c4:1::/64                    ::                  256 ActiveStore

 

TRACERT

Description: Trace route. Shows the IP route to a host, including all the hops between your computer and that host.

PowerShell: Test-NetConnection –TraceRoute

Sample command lines:

  • Test-NetConnection www.microsoft.com –TraceRoute
  • Test-NetConnection outlook.com -TraceRoute | Select -ExpandProperty TraceRoute | % { Resolve-DnsName $_ -type PTR -ErrorAction SilentlyContinue }

Sample output:

PS C:\> Test-NetConnection www.microsoft.com–TraceRoute

ComputerName           : www.microsoft.com
RemoteAddress          : 104.66.197.237
InterfaceAlias         : Wi-Fi
SourceAddress          : 192.168.1.2
PingSucceeded          : True
PingReplyDetails (RTT) : 16 ms
TraceRoute             : 192.168.1.1
                         10.0.0.1
                         TimedOut
                         68.86.113.181
                         69.139.164.2
                         68.85.240.94
                         68.86.93.165
                         68.86.83.126
                         104.66.197.237

PS C:\> Test-NetConnection outlook.com -TraceRoute | Select -ExpandProperty TraceRoute | % { Resolve-DnsName $_ -type PTR -ErrorAction SilentlyContinue }

Name                           Type   TTL   Section    NameHost
----                           ----   ---   -------    --------
125.144.85.68.in-addr.arpa     PTR    7200  Answer     te-0-1-0-10-sur02.bellevue.wa.seattle.comcast.net
142.96.86.68.in-addr.arpa      PTR    4164  Answer     be-1-sur03.bellevue.wa.seattle.comcast.net
6.164.139.69.in-addr.arpa      PTR    2469  Answer     be-40-ar01.seattle.wa.seattle.comcast.net
165.93.86.68.in-addr.arpa      PTR    4505  Answer     be-33650-cr02.seattle.wa.ibone.comcast.net
178.56.167.173.in-addr.arpa    PTR    7200  Answer     as8075-1-c.seattle.wa.ibone.comcast.net
248.82.234.191.in-addr.arpa    PTR    3600  Answer     ae11-0.co2-96c-1a.ntwk.msn.net

 

NETSTAT

Description: Shows current TCP/IP network connections.

PowerShell: Get-NetTCPConnection

Sample command lines:

  • Get-NetTCPConnection | Group State, RemotePort | Sort Count | FT Count, Name –Autosize
  • Get-NetTCPConnection | ? State -eq Established | FT –Autosize
  • Get-NetTCPConnection | ? State -eq Established | ? RemoteAddress -notlike 127* | % { $_; Resolve-DnsName $_.RemoteAddress -type PTR -ErrorAction SilentlyContinue }

Sample output:

PS C:\> Get-NetTCPConnection | Group State, RemotePort | Sort Count | FT Count, Name -Autosize

Count Name
----- ----
    1 SynSent, 9100
    1 Established, 40028
    1 Established, 65001
    1 Established, 27015
    1 Established, 5223
    1 Established, 49227
    1 Established, 49157
    1 Established, 49156
    1 Established, 12350
    1 Established, 49200
    2 Established, 5354
    2 TimeWait, 5357
    2 Established, 80
    3 Established, 443
   36 Listen, 0

PS C:\> Get-NetTCPConnection | ? State -eq Established | FT -Autosize

LocalAddress LocalPort RemoteAddress   RemotePort State       AppliedSetting
------------ --------- -------------   ---------- -----       --------------
127.0.0.1    65001     127.0.0.1       49200      Established Internet
192.168.1.2  59619     91.190.218.57   12350      Established Internet
192.168.1.2  57993     213.199.179.175 40028      Established Internet
192.168.1.2  54334     17.158.28.49    443        Established Internet
192.168.1.2  54320     96.17.8.170     80         Established Internet
192.168.1.2  54319     23.3.105.144    80         Established Internet
192.168.1.2  54147     65.55.68.119    443        Established Internet
192.168.1.2  49257     17.143.162.214  5223       Established Internet
127.0.0.1    49227     127.0.0.1       27015      Established Internet
127.0.0.1    49200     127.0.0.1       65001      Established Internet
192.168.1.2  49197     157.56.98.92    443        Established Internet
127.0.0.1    49157     127.0.0.1       5354       Established Internet
127.0.0.1    49156     127.0.0.1       5354       Established Internet
127.0.0.1    27015     127.0.0.1       49227      Established Internet
127.0.0.1    5354      127.0.0.1       49157      Established Internet
127.0.0.1    5354      127.0.0.1       49156      Established Internet

PS C:\> Get-NetTCPConnection | ? State -eq Established | ? RemoteAddress -notlike 127* | % { $_; Resolve-DnsName $_.RemoteAddress -type PTR -ErrorAction SilentlyContinue }

LocalAddress                        LocalPort RemoteAddress                       RemotePort State       AppliedSetting
------------                        --------- -------------                       ---------- -----       --------------
192.168.1.2                         59619     91.190.218.57                       12350      Established Internet
192.168.1.2                         57993     213.199.179.175                     40028      Established Internet
192.168.1.2                         54334     17.158.28.49                        443        Established Internet
192.168.1.2                         54320     96.17.8.170                         80         Established Internet

Name      : 170.8.17.96.in-addr.arpa
QueryType : PTR
TTL       : 86377
Section   : Answer
NameHost  : a96-17-8-170.deploy.akamaitechnologies.com

192.168.1.2                         54319     23.3.105.144                        80         Established Internet

Name      : 144.105.3.23.in-addr.arpa
QueryType : PTR
TTL       : 7
Section   : Answer
NameHost  : a23-3-105-144.deploy.static.akamaitechnologies.com

192.168.1.2                         54147     65.55.68.119                        443        Established Internet

Name      : 119.68.55.65.in-addr.arpa
QueryType : PTR
TTL       : 850
Section   : Answer
NameHost  : snt404-m.hotmail.com

192.168.1.2                         49257     17.143.162.214                      5223       Established Internet

192.168.1.2                         49197     157.56.98.92                        443        Established Internet

Name      : 92.98.56.157.in-addr.arpa
QueryType : PTR
TTL       : 3600
Section   : Answer
NameHost  : bn1wns1011516.wns.windows.com

Note: Including a PDF version of the output in case you can't see it too well on the web with the lines wrapping and all. See below.

The Deprecation of SMB1 – You should be planning to get rid of this old SMB dialect

$
0
0

I regularly get a question about when will SMB1 be completely removed from Windows. This blog post summarizes the current state of this old SMB dialect in Windows client and server.

 

1) SMB1 is deprecated, but not yet removed

We already added SMB1 to the Windows Server 2012 R2 deprecation list in June 2013. That does not mean it’s fully removed, but that the feature is “planned for potential removal in subsequent releases”. You can find the Windows Server 2012 R2 deprecation list at https://technet.microsoft.com/en-us/library/dn303411.aspx.

 

2) Windows Server 2003 is going away

The last supported Windows operating system that can only negotiate SMB1 is Windows Server 2003. All other currently supported Windows operating systems (client and server) are able to negotiate SMB2 or higher. Windows Server 2003 support will end on July 14 of this year, as you probably heard.

 

3) SMB versions in current releases of Windows and Windows Server

Aside from Windows Server 2003, all other versions of Windows (client and server) support newer versions of SMB:

  • Windows Server 2008 or Windows Vista – SMB1 or SMB2
  • Windows Server 2008 R2 or Windows 7 – SMB1 or SMB2
  • Windows Server 2012 and Windows 8 – SMB1, SMB2 or SMB3
  • Windows Server 2012 R2 and Windows 8.1 – SMB1, SMB2 or SMB3

For details on specific dialects and how they are negotiated, see this blog post on SMB dialects and Windows versions.

image 

4) SMB1 removal in Windows Server 2012 R2 and Windows 8.1

In Windows Server 2012 R2 and Windows 8.1, we made SMB1 an optional component that can be completely removed. That optional component is enabled by default, but a system administrator now has the option to completely disable it. For more details, see this blog post on how to completely remove SMB1 in Windows Server 2012 R2.

 

5) SMB1 removal in Windows 10 Technical Preview and Windows Server Technical Preview

SMB1 will continue to be an optional component enabled by default with Windows 10, which is scheduled to be released in 2015. The next version of Windows Server, which is expected in 2016, will also likely continue to have SMB as an optional component enabled by default. In that release we will add an option to audit SMB1 usage, so IT Administrators can assess if they can disable SMB1 on their own.

 

6) What you should be doing about SMB1

If you are a systems administrator and you manage IT infrastructure that relies on SMB1, you should prepare to remove SMB1.  Once Windows Server 2003 is gone, the main concern will be third party software or hardware like printers, scanners, NAS devices and WAN accelerators. You should make sure that any new software and hardware that requires the SMB protocol is able to negotiate newer versions (at least SMB2, preferably SMB3). For existing devices and software that only support SMB1, you should contact the manufacturer for updates to support the newer dialects.

If you are a software or hardware manufacturer that has a dependency on the SMB1 protocol, you should have a clear plan for removing any such dependencies. Your hardware or software should be ready to operate in an environment where Windows clients and servers only support SMB2 or SMB3. While it’s true that today SMB1 still works in most environments, the fact that the feature is deprecated is a warning that it could go away at any time.

 

7) Complete removal of SMB1

Since SMB1 is a deprecated component, we will assess for its complete removal with every new release.

What’s new in SMB 3.1.1 in the Windows Server 2016 Technical Preview 2

$
0
0

 

1. Introduction

Every new version of Windows brings updates to our main remote file protocol, known as SMB (Server Message Block).

If you’re not familiar with it, you can find some information in this previous blog post: Windows Server 2012 R2: Which version of the SMB protocol (SMB 1.0, SMB 2.0, SMB 2.1, SMB 3.0 or SMB 3.02) are you using?

In this blog post, you’ll see what changed with the new version of SMB that comes with the Windows 10 Insider Preview released in late April 2015 and the Windows Server 2016 Technical Preview 2 released in early May 2015.

 

2. Protocols Changes in SMB 3.1.1

This section covers changes in SMB 3.1.1 related to the protocol itself.

The Protocol Preview document fully describes these changes: [MS-SMB2-Diff]- Server Message Block (SMB) Protocol Versions 2 and 3, but you can see the highlights below.

 

2.1. Pre-Authentication Integrity

Pre-authentication integrity provides improved protection from a man-in-the-middle attacker tampering with SMB’s connection establishment and authentication messages.

Pre-Auth integrity verifies all the “negotiate” and “session setup” exchanges used by SMB with a strong cryptographic hash (SHA-512).

If your client and your server establish an SMB 3.1.1 session, you can be sure that no one has tampered with the connection and session properties.

Using SMB signing on top of an SMB 3.1.1 session protects you from an attacker tampering with any packets.

Using SMB encryption on top of an SMB 3.1.1 session protects you from an attacker tampering with or eavesdropping on any packets.

Although there is a cost to enable SMB signing or SMB encryption, we highly recommend enabling one of them.

Note: While these changes improve overall security, they might interfere with some solutions that rely on modifying SMB network traffic, like certain kinds of WAN accelerators.

 

2.2. SMB Encryption Improvements

SMB Encryption, introduced with SMB 3.0, used a fixed cryptographic algorithm: AES-128-CCM.

Since then, we have learned that AES-128-GCM performs better in most modern processors.

To take advantage of that, SMB 3.1.1 offers a mechanism to negotiate the crypto algorithm per connection, with options for AES-128-CCM and AES-128-GCM.

We made AES-128-GCM the default for new Windows versions, while older versions will continue to use AES-128-CCM.

With this flexible infrastructure for negotiation in place, we could add more algorithms in the future.

We observed that moving from AES-128-CCM to AES-128-GCM showed a 2x improvement in certain scenarios, like copying large files over an encrypted SMB connection.

 

2.3. Cluster Dialect Fencing

Provides support for cluster rolling upgrade for Scale-Out File Servers. For details, see http://technet.microsoft.com/en-us/library/dn765474.aspx#BKMK_RollingUpgrade

In this new scenario, a single SMB server appears to support different maximum dialects of SMB, depending on whether the SMB client is accessing clustered or non-clustered file shares.

For local, non-clustered file shares, the server offers up to 3.1.1 during dialect negotiation.

For clustered shares, if the cluster is in mixed mode (before upgrading the cluster functional level), it will offer up to 3.0.2 during dialect negotiation.

After you upgrade the cluster functional level, it then offers all clients the new 3.1.1 dialect.

 

3. Other SMB changes that are not protocol-related

There are other changes in Windows that change the SMB Client or SMB Server implementation, but not the protocol itself.

Here are a few important changes in that category:

 

3.1. Removing RequireSecureNegotiate setting

In previous versions of SMB, we introduced “Secure Negotiate”, where the SMB client and server verify integrity of the SMB negotiate request and response messages.

Because some third-party implementations of SMB did not correctly perform this negotiation, we introduced a switch to disable “Secure Negotiate”. We explain this in more detail in this blog post.

Since we have learned via our SMB PlugFests that third parties have fixed their implementations, we are removing the option to bypass “Secure Negotiate” and SMB always performs negotiate validation if the connection’s dialect is 2.x.x or 3.0.x.

Note 1: For SMB 3.1.1 clients and servers, the new Pre-Authentication Integrity feature (described in item 2.1 above) supersedes “Secure Negotiate” with many advantages.

Note 2: With the new release, any third party SMB 2.x.x or SMB 3.0.x implementations that do not implement “Secure Negotiate” will be unable to connect to Windows.

Note 3: While this change improves overall security, it might interfere with some solutions that rely on modifying SMB network traffic, like certain kinds of WAN accelerators.

 

3.2. Dialects with non-zero revision number now reported with the x.y.z notation

As you probably noticed throughout this blog post, we’re using 3 separate digits to notate the version of SMB.

In the past, you might have seen us talk about SMB 3.02. Now we call that SMB 3.0.2.

Note that there is no change when the revision number is 0, like SMB 2.1 or SMB 3.0 (we don’t call them SMB 2.1.0 or SMB 3.0.0).

This new format avoids confusion when comparing SMB dialects and better represents the actual version information used by SMB.

You can use the Get-SmbConnection cmdlet on the Windows SMB client to report the currently used SMB dialects.

 

4. Which protocol is negotiated?

Please note that SMB clients and SMB servers negotiate the SMB dialect that they will use based on each side’s offer.

Here’s a table to help you understand what version you will end up using, depending on what Windows version is running as the SMB client and what version of Windows is running as the SMB server:

 

OS

Windows 10
WS* 2016 TP2

Windows 8.1
WS* 2012 R2

Windows 8
WS* 2012

Windows 7
WS* 2008 R2

Windows Vista
WS* 2008

Previous
versions

Windows 10
WS* 2016 TP2

SMB 3.1.1

SMB 3.0.2

SMB 3.0

SMB 2.1

SMB 2.0.2

SMB 1.x

Windows 8.1
WS* 2012 R2

SMB 3.0.2

SMB 3.0.2

SMB 3.0

SMB 2.1

SMB 2.0.2

SMB 1.x

Windows 8
WS* 2012

SMB 3.0

SMB 3.0

SMB 3.0

SMB 2.1

SMB 2.0.2

SMB 1.x

Windows 7
WS* 2008 R2

SMB 2.1

SMB 2.1

SMB 2.1

SMB 2.1

SMB 2.0.2

SMB 1.x

Windows Vista
WS* 2008

SMB 2.0.2

SMB 2.0.2

SMB 2.0.2

SMB 2.0.2

SMB 2.0.2

SMB 1.x

Previous
versions

SMB 1.x

SMB 1.x

SMB 1.x

SMB 1.x

SMB 1.x

SMB 1.x

* WS = Windows Server

 

Note: Earlier Windows 10 and Windows Server 2016 previews used SMB dialect version 3.1.

 

5. Considering your options for removing the older SMB1 protocol

When Windows Server 2003 hits the end of its extended support later this year, the last supported version of Windows that only works with SMB1 will be gone.

SMB1 is already a separate component in Windows that you can completely remove. However, up to this point, Windows still enables it by default for compatibility reasons.

The next logical step (which we are planning for a future release of Windows) will be to ship SMB1 disabled by default, but still available if necessary.

To help with this transition, you can now enable auditing of SMB1 traffic in your SMB server using PowerShell. This will alert you via events if any clients are still using SMB1.

To enable auditing of SMB1 traffic, use the cmdlet: Set-SmbServerConfiguration –AuditSmb1Access $true

To view the SMB1 events, use the cmdlet: Get-WinEvent -LogName Microsoft-Windows-SMBServer/Audit

If you feel confident that there are no SMB1 clients in your network, you can uninstall SMB1 from your server using the cmdlet: Remove-WindowsFeature FS-SMB1

 

6. Conclusion

I hope this blog post helps you prepare for the upcoming changes in SMB.

We also recommend that you download the SNIA Tutorial on SMB 3, which we recently updated to include details of the 3.1.1 dialect. You can find a copy of that tutorial at http://www.snia.org/sites/default/files2/DSI2015/presentations/FileSystems/JoseBarreto_SMB3_remote%20file%20protocol.pdf

Windows Server 2016 Technical Preview 2 (TP2) and Storage Quality of Service (QoS)

$
0
0

 

Storage Quality of Service (Storage QoS) is a new feature in the upcoming Windows Server 2016 that provides a way to centrally monitor and manage storage performance for virtual machines. The feature automatically improves storage resource fairness between multiple virtual machines using the same file server cluster and allows specific minimum and maximum performance goals (Storage QoS policies) to be configured in units of normalized 8KB IOPs.

 

image

 

With the release of Windows Server 2016 Technical Preview 2 (TP2), the Storage QoS feature is available for testing. Virtual Machine Manager 2016 TP2 also includes the ability to manage Storage QoS. Find below some important links to review so you can experiment with Storage QoS in Windows Server 2016 TP2:

 

Download link for Windows Server 2016 TP2 and System Center 2016 TP2:

 

TechNet Guide for Windows Server 2016 TP2 and Storage QoS:

 

Microsoft Ignite 2015 session on Windows Server 2016 TP2 and Storage QoS:

 

Storage QoS demos (videos):

 

Storage QoS script samples

PowerShell script used in the Windows Server 2016 TP2 Storage QoS demo at MSIgnite

$
0
0

 

This is the Windows PowerShell script I used in the Microsoft Ignite 2015 session on Storage QoS: Hyper-V Storage Performance with Storage Quality of Service. You can also find that demo video by itself at Windows Server 2016 TP2 Storage QoS: Managing with a PowerShell script.

 

The script is fairly straightforward, but there a few interesting points to make about what it does:

  • The script is designed to run from a separate management computer, so all Storage QoS cmdlets use the –CimSession option to point to the Scale-Out File Server.
  • There is a handy function called “Get-PolicyName” that translates a PolicyID into a PolicyName by using Get-StorageQosPolicy.
  • It shows how to filter output of Get-StorageQosFlow. It remove the default policy entries from the list and and sorts the list by VM name (InitiatorName).
  • It offers a good example of how to use Expressions to format the output of Get-StorageQosFlow.
  • It uses the $LastChange variable to later show the time passed since the QoS policies were changed with Set-StorageQosPolicy, since the Get-StorageQosFlow is an average for the last 5 minutes.

 

Here’s the script:

# QosDemo.ps1 – Storage QoS demo script for Microsoft Ignite 2015

Function Get-PolicyName([string] $PolicyID)
{
     $Policy = Get-StorageQosPolicy -CimSession JOSEBDA-FS -PolicyID $PolicyID  
     Return $Policy.Name
}

$LastChange = Get-Date
$Option = "R"

While ($Option -ne "Q") {

    Clear-Host

    Write-Host -ForegroundColor Yellow "C:\> Get-StorageQosFlow |”
    Write-Host -ForegroundColor Yellow “FT InitiatorNodeName, InitiatorName, FilePath, MinimumIOPS, MaximumIOPS, InitiatorIOPS, InitiatorLatency, PolicyID"

    Get-StorageQosFlow -CimSession JOSEBDA-FS | ? InitiatorName -ne "" | Sort InitiatorName |
    FT @{Expression={$_.InitiatorNodeName.Split(".")[0]}; Label="Node"},
       @{Expression={$_.InitiatorName}; Label="VM"},
       @{Expression={$_.FilePath.Split("\")[4]}; Label="File"},
       @{Expression={$_.MinimumIOPS}; Label="MinIOPS"},
       @{Expression={$_.MaximumIOPS}; Label="MaxIOPS"},
       @{Expression={$_.InitiatorIOPS}; Label="VM IOPS"},
       @{Expression={[int] $_.InitiatorLatency}; Label="Latency"},
       @{Expression={(Get-PolicyName $_.PolicyID)}; Label="Policy"},
       PolicyID  -AutoSize

    $TimeDiff = (Get-Date) - $LastChange
    $Minutes = [System.Math]::Round($TimeDiff.TotalMinutes, 2)
    $Seconds = [System.Math]::Round($TimeDiff.TotalSeconds, 2)

    Write-Host "IOPS and Latency are 5-minute averages. Last policy change $Seconds seconds ago ($Minutes minutes ago)."
    Write-Host

    Write-Host -ForegroundColor Yellow "C:\> Get-StorageQosPolicy | FT Name, PolicyType, MinimumIOPS, MaximumIOPS, PolicyID"
    Get-StorageQosPolicy -CimSession JOSEBDA-FS | FT Name, PolicyType, MinimumIOPS, MaximumIOPS, PolicyID -AutoSize

    Write-Host -NoNewline "Command: Quit, Refresh, Zero, Low, High: "
    $Option = Read-Host
    $Option = $Option.ToUpper()[0]

    Switch ($Option) {

    "Z" {
            Set-StorageQosPolicy -CimSession JOSEBDA-FS -Name SilverVM -MinimumIops 0 -MaximumIops 0
            Set-StorageQosPolicy -CimSession JOSEBDA-FS -Name GoldVM -MinimumIops 0 -MaximumIops 0
            $LastChange = Get-Date
        }

    "L" {
            Set-StorageQosPolicy -CimSession JOSEBDA-FS -Name SilverVM -MinimumIops 200 -MaximumIops 500
            Set-StorageQosPolicy -CimSession JOSEBDA-FS -Name GoldVM -MinimumIops 500 -MaximumIops 1000
            $LastChange = Get-Date
        }

    "H" {
            Set-StorageQosPolicy -CimSession JOSEBDA-FS -Name SilverVM -MinimumIops 500 -MaximumIops 1000
            Set-StorageQosPolicy -CimSession JOSEBDA-FS -Name GoldVM -MinimumIops 1000 -MaximumIops 5000
            $LastChange = Get-Date
        }

    } #end switch

} #end while


Microsoft SharePoint Server 2013 PowerShell cmdlet popularity

$
0
0

 

If you follow the blog, you probably saw a little PowerShell script I published a while back to measure the popularity of the cmdlets in a certain module using a Bing search. As an example, that blog showed the popularity of the cmdlets in the SmbShare module.

 

Now I got curious about how the cmdlets in other modules would rank, so I spun up some Azure virtual machines to try some other modules. I decided to try the Microsoft SharePoint Server 2013 module (named Microsoft.SharePoint.PowerShell).

image

 

The results are listed below:

PS C:\> .\PopularCmdlet.ps1 | Sort BingCount -Descending | FT -AutoSize

CmdletName                                                        BingCount
----------                                                        ---------
New-SPSite                                                           480000
Get-SPWeb                                                            187000
Get-SPSite                                                           114000
Get-SPWebApplication                                                  70700
New-SPTrustedSecurityTokenIssuer                                      48300
Add-SPShellAdmin                                                      45200
Mount-SPContentDatabase                                               44500
Enable-SPFeature                                                      44300
Import-SPWeb                                                          43300
Restore-SPSite                                                        42900
Add-SPSolution                                                        40700
Install-SPSolution                                                    38000
Get-SPUser                                                            37800
Export-SPWeb                                                          37200
New-SPConfigurationDatabase                                           36700
Get-SPServiceInstance                                                 35800
Get-SPServiceApplication                                              35600
Backup-SPSite                                                         35200
Get-SPFarm                                                            33000
Register-SPWorkflowService                                            31100
New-SPWeb                                                             30200
Get-SPDatabase                                                        30100
Upgrade-SPContentDatabase                                             29900
Test-SPContentDatabase                                                29800
New-SPWebApplication                                                  29700
Move-SPUser                                                           28500
Get-SPFeature                                                         27700
Enable-SPUserLicensing                                                26600
Get-SPEnterpriseSearchServiceApplication                              25200
Get-SPUserLicensing                                                   24700
Backup-SPFarm                                                         24600
Disable-SPUserLicensing                                               24400
Set-SPUser                                                            24300
Disable-SPFeature                                                     24200
Copy-SPSite                                                           24200
Get-SPContentDatabase                                                 23300
Uninstall-SPSolution                                                  23100
Update-SPSolution                                                     21600
Remove-SPSite                                                         21300
Set-SPSite                                                            20800
Get-SPTimerJob                                                        20600
Get-SPManagedAccount                                                  20400
New-SPWOPIBinding                                                     19500
Update-SPProfilePhotoStore                                            19400
Start-SPServiceInstance                                               19300
New-SPUser                                                            18800
Stop-SPAssignment                                                     18700
New-SPTrustedIdentityTokenIssuer                                      18400
Set-SPEnterpriseSearchServiceApplication                              18100
New-SPManagedAccount                                                  17400
New-SPEnterpriseSearchServiceApplication                              17300
Get-SPLogEvent                                                        17000
New-SPCentralAdministration                                           16900
Remove-SPUser                                                         16300
Get-SPEnterpriseSearchServiceInstance                                 16300
New-SPProfileServiceApplication                                       16100
Get-SPSecurityTokenServiceConfig                                      16000
New-SPContentDatabase                                                 15700
Install-SPFeature                                                     15300
Restore-SPFarm                                                        15200
Get-SPSolution                                                        14800
Get-SPShellAdmin                                                      14600
Start-SPEnterpriseSearchServiceInstance                               14500
Get-SPServer                                                          14200
Connect-SPConfigurationDatabase                                       14200
Set-SPWeb                                                             14100
Stop-SPServiceInstance                                                13800
Dismount-SPContentDatabase                                            13700
Get-SPServiceApplicationPool                                          13700
New-SPServiceApplicationPool                                          13500
Convert-SPWebApplication                                              13500
Get-SPServiceContext                                                  13500
Merge-SPLogFile                                                       13500
Set-SPManagedAccount                                                  13400
Start-SPAssignment                                                    13100
Add-SPDistributedCacheServiceInstance                                 12900
Upgrade-SPSite                                                        12800
Get-SPServiceApplicationProxy                                         12800
Remove-SPWeb                                                          12600
Remove-SPSolution                                                     12400
Get-SPWOPIBinding                                                     12000
Get-SPWebTemplate                                                     11700
Start-SPAdminJob                                                      11400
Get-SPEnterpriseSearchService                                         11000
New-SPClaimsPrincipal                                                 10900
Remove-SPWOPIBinding                                                  10800
Restore-SPDeletedSite                                                 10800
Get-SPProduct                                                         10600
Install-SPService                                                     10600
Uninstall-SPFeature                                                   10600
Enable-SPSessionStateService                                          10500
Set-SPWebApplication                                                  10400
New-SPUsageApplication                                                10400
Remove-SPDeletedSite                                                  10400
Import-SPMetadataWebServicePartitionData                              10100
New-SPMetadataServiceApplication                                      10100
Set-SPEnterpriseSearchTopology                                        10100
New-SPSecureStoreServiceApplication                                   10000
Get-SPDeletedSite                                                      9880
Get-SPTrustedSecurityTokenIssuer                                       9730
New-SPSubscriptionSettingsServiceApplication                           9730
Get-SPTrustedIdentityTokenIssuer                                       9660
Get-SPUsageDefinition                                                  9580
Set-SPEnterpriseSearchCrawlDatabase                                    9360
Get-SPEnterpriseSearchStatus                                           9330
New-SPStateServiceDatabase                                             9320
Set-SPSiteURL                                                          9060
Set-SPUsageDefinition                                                  8870
Test-SPSite                                                            8840
Set-SPEnterpriseSearchService                                          8520
New-SPClaimTypeMapping                                                 8430
New-SPEnterpriseSearchCrawlComponent                                   8370
Set-SPAppSiteSubscriptionName                                          8320
Rename-SPServer                                                        8280
Remove-SPClaimProvider                                                 8230
Repair-SPManagedAccountDeployment                                      8070
Set-SPProfileServiceApplication                                        8060
New-SPEnterpriseSearchServiceApplicationProxy                          8040
Get-SPEnterpriseSearchCrawlContentSource                               7980
Remove-SPWebApplication                                                7960
Remove-SPServiceApplication                                            7940
New-SPAuthenticationProvider                                           7930
Restore-SPEnterpriseSearchServiceApplication                           7930
Get-SPSiteAdministration                                               7670
Get-SPAppPrincipal                                                     7610
Disconnect-SPConfigurationDatabase                                     7600
Remove-SPDistributedCacheServiceInstance                               7480
Set-SPBusinessDataCatalogThrottleConfig                                7460
Set-SPPassPhrase                                                       7410
Register-SPAppPrincipal                                                7360
New-SPEnterpriseSearchAdminComponent                                   7320
Remove-SPContentDatabase                                               7280
Install-SPUserSolution                                                 7170
Get-SPEnterpriseSearchMetadataManagedProperty                          7120
Set-SPUsageService                                                     7080
Move-SPProfileManagedMetadataProperty                                  7070
Export-SPMetadataWebServicePartitionData                               7060
Set-SPCustomLayoutsPage                                                7010
Set-SPMetadataServiceApplication                                       7010
Upgrade-SPSingleSignOnDatabase                                         6950
Set-SPLogLevel                                                         6910
New-SPClaimTypeEncoding                                                6910
New-SPEnterpriseSearchIndexComponent                                   6750
Set-SPFarmConfig                                                       6690
Add-SPUserSolution                                                     6610
Add-SPProfileSyncConnection                                            6500
Set-SPAppDomain                                                        6360
Install-SPDataConnectionFile                                           6360
Set-SPDiagnosticsProvider                                              6340
Set-SPEnterpriseSearchAdministrationComponent                          6320
Get-SPEnterpriseSearchTopology                                         6280
Install-SPApplicationContent                                           6270
Update-SPDistributedCacheSize                                          6250
Set-SPWOPIBinding                                                      6250
Get-SPClaimProvider                                                    6250
Get-SPCertificateAuthority                                             6200
Import-SPAppPackage                                                    6190
Get-SPBusinessDataCatalogMetadataObject                                6080
New-SPSecureStoreApplication                                           6030
Install-SPApp                                                          6020
New-SPEnterpriseSearchQueryScope                                       6020
Remove-SPManagedAccount                                                6000
Remove-SPTrustedIdentityTokenIssuer                                    5900
Install-SPHelpCollection                                               5870
Remove-SPEnterpriseSearchComponent                                     5840
New-SPSubscriptionSettingsServiceApplicationProxy                      5790
Add-SPProfileLeader                                                    5790
Suspend-SPEnterpriseSearchServiceApplication                           5780
Get-SPLogLevel                                                         5770
Get-SPAlternateURL                                                     5700
Initialize-SPResourceSecurity                                          5700
Set-SPEnterpriseSearchCrawlContentSource                               5700
Get-SPPendingUpgradeActions                                            5650
New-SPWOPISuppressionSetting                                           5640
Remove-SPServiceApplicationPool                                        5640
Get-SPTaxonomySession                                                  5630
Remove-SPEnterpriseSearchServiceApplication                            5590
Update-SPSecureStoreApplicationServerKey                               5550
Set-SPServiceApplicationSecurity                                       5530
Set-SPTrustedIdentityTokenIssuer                                       5530
Stop-SPDistributedCacheServiceInstance                                 5520
Get-SPEnterpriseSearchMetadataCrawledProperty                          5510
New-SPEnterpriseSearchTopology                                         5490
Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance            5420
Get-SPWOPIZone                                                         5390
New-SPEnterpriseSearchMetadataManagedProperty                          5390
Revoke-SPObjectSecurity                                                5320
Start-SPTimerJob                                                       5310
New-SPEnterpriseSearchCrawlContentSource                               5300
Get-SPAuthenticationRealm                                              5300
Grant-SPObjectSecurity                                                 5270
Set-SPUsageApplication                                                 5260
Set-SPTimerJob                                                         5240
Set-SPSecurityTokenServiceConfig                                       5230
New-SPEnterpriseSearchMetadataCrawledProperty                          5220
Receive-SPServiceApplicationConnectionInfo                             5210
Set-SPSiteSubscriptionConfig                                           5160
New-SPWebApplicationAppDomain                                          5160
Set-SPCentralAdministration                                            5150
Get-SPBusinessDataCatalogThrottleConfig                                5110
New-SPManagedPath                                                      5110
Resume-SPEnterpriseSearchServiceApplication                            5090
Uninstall-SPAppInstance                                                5080
Get-SPAppInstance                                                      5060
Get-SPEnterpriseSearchQueryScope                                       5060
Add-SPSiteSubscriptionProfileConfig                                    5040
New-SPEnterpriseSearchLanguageResourcePhrase                           5020
Set-SPWOPIZone                                                         5010
New-SPAppManagementServiceApplication                                  5000
New-SPEnterpriseSearchCrawlDatabase                                    4980
Remove-SPServiceApplicationProxy                                       4930
New-SPEnterpriseSearchCrawlRule                                        4920
Remove-SPSiteURL                                                       4890
Stop-SPEnterpriseSearchServiceInstance                                 4840
New-SPProfileServiceApplicationProxy                                   4840
New-SPEnterpriseSearchQueryProcessingComponent                         4830
Upgrade-SPEnterpriseSearchServiceApplication                           4800
New-SPEnterpriseSearchQueryScopeRule                                   4750
New-SPUserLicenseMapping                                               4750
Install-SPWebPartPack                                                  4690
Get-SPServiceHostConfig                                                4690
Get-SPEnterpriseSearchServiceApplicationProxy                          4650
New-SPBusinessDataCatalogServiceApplication                            4650
New-SPSiteSubscription                                                 4640
Get-SPEnterpriseSearchMetadataCategory                                 4620
Remove-SPShellAdmin                                                    4580
New-SPMetadataServiceApplicationProxy                                  4560
Set-SPAppPrincipalPermission                                           4560
New-SPEnterpriseSearchAnalyticsProcessingComponent                     4540
Set-SPContentDatabase                                                  4520
Get-SPSiteSubscription                                                 4500
Get-SPEnterpriseSearchQueryKeyword                                     4480
Remove-SPEnterpriseSearchCrawlContentSource                            4480
Import-SPEnterpriseSearchThesaurus                                     4420
Get-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance              4410
Get-SPSessionStateService                                              4410
Repair-SPSite                                                          4410
Get-SPServiceApplicationSecurity                                       4410
Remove-SPBusinessDataCatalogModel                                      4390
Set-SPMetadataServiceApplicationProxy                                  4390
New-SPSiteSubscriptionFeaturePack                                      4380
New-SPEnterpriseSearchSecurityTrimmer                                  4380
Remove-SPTrustedSecurityTokenIssuer                                    4340
Set-SPEnterpriseSearchRankingModel                                     4310
Get-SPSecureStoreApplication                                           4300
Get-SPSiteSubscriptionFeaturePack                                      4300
Get-SPEnterpriseSearchCrawlDatabase                                    4270
Set-SPIRMSettings                                                      4260
Remove-SPTrustedRootAuthority                                          4240
Set-SPServiceApplicationPool                                           4240
Get-SPEnterpriseSearchCrawlCustomConnector                             4230
Remove-SPEnterpriseSearchQueryScope                                    4210
Get-SPEnterpriseSearchComponent                                        4200
Get-SPEnterpriseSearchQuerySuggestionCandidates                        4200
Get-SPEnterpriseSearchOwner                                            4190
Get-SPEnterpriseSearchRankingModel                                     4190
Set-SPProfileServiceApplicationSecurity                                4190
Get-SPSiteURL                                                          4180
Remove-SPEnterpriseSearchLanguageResourcePhrase                        4170
Set-SPEnterpriseSearchServiceInstance                                  4160
Update-SPInfoPathUserFileUrl                                           4160
Update-SPUserSolution                                                  4150
New-SPAlternateURL                                                     4150
Import-SPEnterpriseSearchTopology                                      4130
Get-SPTopologyServiceApplication                                       4120
Grant-SPBusinessDataCatalogMetadataObject                              4090
Get-SPEnterpriseSearchFileFormat                                       4090
Set-SPEnterpriseSearchContentEnrichmentConfiguration                   4080
Remove-SPEnterpriseSearchCrawlMapping                                  4070
Get-SPEnterpriseSearchQueryScopeRule                                   4070
New-SPEnterpriseSearchCrawlExtension                                   4070
Get-SPUserLicense                                                      4040
Set-SPEnterpriseSearchMetadataManagedProperty                          4030
Get-SPStateServiceApplication                                          4020
Publish-SPServiceApplication                                           3990
New-SPODataConnectionSetting                                           3980
Get-SPUserSolution                                                     3980
Uninstall-SPUserSolution                                               3980
Remove-SPEnterpriseSearchMetadataManagedProperty                       3970
Set-SPEnterpriseSearchMetadataMapping                                  3970
Remove-SPEnterpriseSearchTopology                                      3960
New-SPServiceApplicationProxyGroup                                     3940
Get-SPSiteSubscriptionConfig                                           3930
Backup-SPConfigurationDatabase                                         3920
Set-SPSiteAdministration                                               3910
Set-SPAuthenticationRealm                                              3900
Add-SPSiteSubscriptionFeaturePackMember                                3890
Remove-SPEnterpriseSearchCrawlCustomConnector                          3890
Remove-SPSiteSubscription                                              3890
Get-SPEnterpriseSearchMetadataMapping                                  3880
Get-SPTrustedRootAuthority                                             3880
New-SPEnterpriseSearchSiteHitRule                                      3870
Get-SPEnterpriseSearchLanguageResourcePhrase                           3870
Get-SPFarmConfig                                                       3870
Remove-SPEnterpriseSearchCrawlDatabase                                 3850
Set-SPEnterpriseSearchQueryScope                                       3840
New-SPAppManagementServiceApplicationProxy                             3840
Remove-SPEnterpriseSearchCrawlRule                                     3840
Add-SPClaimTypeMapping                                                 3830
Remove-SPEnterpriseSearchQueryAuthority                                3820
Get-SPEnterpriseSearchCrawlExtension                                   3820
Set-SPEnterpriseSearchMetadataCrawledProperty                          3810
Remove-SPEnterpriseSearchServiceApplicationProxy                       3810
Remove-SPSiteSubscriptionSettings                                      3800
Get-SPEnterpriseSearchCrawlMapping                                     3800
Remove-SPEnterpriseSearchMetadataCategory                              3790
Import-SPEnterpriseSearchCustomExtractionDictionary                    3790
Set-SPDiagnosticConfig                                                 3780
Update-SPSecureStoreMasterKey                                          3780
Remove-SPEnterpriseSearchQueryScopeRule                                3760
Update-SPAppInstance                                                   3760
Set-SPEnterpriseSearchQueryScopeRule                                   3760
Import-SPBusinessDataCatalogModel                                      3760
Remove-SPEnterpriseSearchMetadataMapping                               3740
Get-SPUsageService                                                     3740
Get-SPEnterpriseSearchSecurityTrimmer                                  3740
Stop-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance             3730
Remove-SPEnterpriseSearchQueryDemoted                                  3720
New-SPEnterpriseSearchFileFormat                                       3720
Remove-SPEnterpriseSearchSiteHitRule                                   3720
New-SPSecureStoreServiceApplicationProxy                               3710
Remove-SPEnterpriseSearchCrawlExtension                                3700
Disable-SPTimerJob                                                     3700
Get-SPEnterpriseSearchQueryAndSiteSettingsService                      3700
Export-SPEnterpriseSearchTopology                                      3700
Remove-SPEnterpriseSearchQueryKeyword                                  3700
New-SPEnterpriseSearchQueryAuthority                                   3700
Get-SPAuthenticationProvider                                           3700
Get-SPEnterpriseSearchQueryAuthority                                   3690
Get-SPDistributedCacheClientSetting                                    3690
Get-SPEnterpriseSearchSiteHitRule                                      3690
Set-SPEnterpriseSearchQueryAuthority                                   3680
Remove-SPEnterpriseSearchRankingModel                                  3680
New-SPEnterpriseSearchCrawlCustomConnector                             3680
Get-SPEnterpriseSearchQueryAndSiteSettingsServiceProxy                 3670
Get-SPEnterpriseSearchQueryDemoted                                     3670
New-SPEnterpriseSearchQueryDemoted                                     3660
Get-SPEnterpriseSearchCrawlRule                                        3650
Set-SPEnterpriseSearchQueryKeyword                                     3640
Set-SPEnterpriseSearchServiceApplicationProxy                          3640
Set-SPEnterpriseSearchMetadataCategory                                 3640
Set-SPBusinessDataCatalogServiceApplication                            3630
Set-SPEnterpriseSearchCrawlRule                                        3630
New-SPEnterpriseSearchQueryKeyword                                     3630
Remove-SPEnterpriseSearchSecurityTrimmer                               3610
New-SPClaimProvider                                                    3600
Get-SPWorkflowServiceApplicationProxy                                  3590
New-SPEnterpriseSearchMetadataCategory                                 3580
Get-SPUsageApplication                                                 3570
Get-SPProfileLeader                                                    3570
Remove-SPClaimTypeMapping                                              3560
Get-SPServiceApplicationProxyGroup                                     3560
Set-SPTrustedRootAuthority                                             3540
Remove-SPUserSolution                                                  3530
New-SPStateServiceApplicationProxy                                     3520
New-SPEnterpriseSearchCrawlMapping                                     3510
Set-SPServiceApplication                                               3480
Get-SPManagedPath                                                      3460
Add-SPUserLicenseMapping                                               3440
Set-SPSiteSubscriptionProfileConfig                                    3430
Set-SPServiceHostConfig                                                3430
Get-SPMetadataServiceApplication                                       3400
New-SPLogFile                                                          3390
Get-SPEnterpriseSearchAdministrationComponent                          3380
Set-SPSubscriptionSettingsServiceApplication                           3370
Remove-SPEnterpriseSearchLinksDatabase                                 3370
Import-SPSiteSubscriptionSettings                                      3340
Request-SPUpgradeEvaluationSite                                        3330
Get-SPCustomLayoutsPage                                                3310
Update-SPWOPIProofKey                                                  3310
Get-SPEnterpriseSearchQuerySpellingCorrection                          3300
Set-SPEnterpriseSearchQuerySpellingCorrection                          3300
Add-SPServiceApplicationProxyGroupMember                               3290
Upgrade-SPFarm                                                         3290
Remove-SPSiteSubscriptionBusinessDataCatalogConfig                     3280
Get-SPProfileServiceApplicationSecurity                                3260
Remove-SPConfigurationDatabase                                         3260
Export-SPSiteSubscriptionSettings                                      3250
Update-SPInfoPathAdminFileUrl                                          3240
Backup-SPEnterpriseSearchServiceApplicationIndex                       3190
New-SPAzureAccessControlServiceApplicationProxy                        3170
Remove-SPTrustedServiceTokenIssuer                                     3140
Update-SPRepopulateMicroblogFeedCache                                  3130
Set-SPClaimProvider                                                    3110
Remove-SPServiceApplicationProxyGroup                                  3100
Initialize-SPStateServiceDatabase                                      3100
Set-SPPerformancePointSecureDataValues                                 3080
Get-SPServiceApplicationEndpoint                                       3070
Get-SPClaimProviderManager                                             3070
Set-SPDistributedCacheClientSetting                                    3030
Get-SPRequestManagementSettings                                        3020
Get-SPTrustedServiceTokenIssuer                                        2990
Add-SPDiagnosticsPerformanceCounter                                    2990
Test-SPInfoPathFormTemplate                                            2970
Start-SPContentDeploymentJob                                           2960
Set-SPBusinessDataCatalogMetadataObject                                2930
Get-SPDiagnosticConfig                                                 2920
Get-SPInfoPathFormTemplate                                             2920
Update-SPFarmEncryptionKey                                             2920
Get-SPInfoPathFormsService                                             2900
Get-SPClaimTypeEncoding                                                2890
Remove-SPProfileSyncConnection                                         2870
Remove-SPSolutionDeploymentLock                                        2870
Get-SPWebPartPack                                                      2870
Get-SPBackupHistory                                                    2870
Remove-SPUsageApplication                                              2860
Remove-SPServiceApplicationProxyGroupMember                            2850
Get-SPWebApplicationHttpThrottlingMonitor                              2810
Get-SPWorkflowConfig                                                   2800
Get-SPSiteUpgradeSessionInfo                                           2800
Get-SPWOPISuppressionSetting                                           2800
Remove-SPSiteSubscriptionFeaturePack                                   2790
Mount-SPStateServiceDatabase                                           2780
Clear-SPLogLevel                                                       2780
Set-SPTrustedServiceTokenIssuer                                        2730
Remove-SPManagedPath                                                   2700
Get-SPDiagnosticsProvider                                              2700
Get-SPHealthAnalysisRule                                               2680
Get-SPMetadataServiceApplicationProxy                                  2620
Update-SPRepopulateMicroblogLMTCache                                   2610
Import-SPInfoPathAdministrationFiles                                   2610
Set-SPWebApplicationHttpThrottlingMonitor                              2600
Enable-SPTimerJob                                                      2590
Export-SPInfoPathAdministrationFiles                                   2590
Set-SPInfoPathFormsService                                             2580
Set-SPTopologyServiceApplication                                       2580
Get-SPHelpCollection                                                   2570
Get-SPInfoPathUserAgent                                                2570
Remove-SPSiteSubscriptionFeaturePackMember                             2570
Set-SPServiceApplicationEndpoint                                       2560
Get-SPStateServiceDatabase                                             2550
Set-SPAlternateURL                                                     2550
Remove-SPSiteSubscriptionProfileConfig                                 2540
Set-SPDataConnectionFile                                               2540
Update-SPInfoPathFormTemplate                                          2530
Unpublish-SPServiceApplication                                         2530
Import-SPBusinessDataCatalogDotNetAssembly                             2510
Add-SPRoutingMachinePool                                               2500
Get-SPDataConnectionFileDependent                                      2500
Get-SPDataConnectionFile                                               2490
Uninstall-SPDataConnectionFile                                         2450
Get-SPPerformancePointServiceApplication                               2420
Remove-SPStateServiceDatabase                                          2400
Set-SPSiteSubscriptionMetadataConfig                                   2400
Get-SPInfoPathWebServiceProxy                                          2400
Set-SPInfoPathWebServiceProxy                                          2380
Add-SPInfoPathUserAgent                                                2360
Remove-SPDiagnosticsPerformanceCounter                                 2360
Get-SPTopologyServiceApplicationProxy                                  2360
Start-SPInfoPathFormTemplate                                           2340
Remove-SPInfoPathUserAgent                                             2330
New-SPPerformancePointServiceApplication                               2300
Set-SPContentDeploymentJob                                             2290
Get-SPContentDeploymentJob                                             2270
Stop-SPInfoPathFormTemplate                                            2260
Move-SPBlobStorageLocation                                             2260
Set-SPInfoPathFormTemplate                                             2260
Export-SPBusinessDataCatalogModel                                      2260
Get-SPDiagnosticsPerformanceCounter                                    2260
Set-SPDesignerSettings                                                 2260
Set-SPProfileServiceApplicationProxy                                   2250
Remove-SPProfileLeader                                                 2250
Get-SPContentDeploymentPath                                            2250
New-SPContentDeploymentPath                                            2240
Update-SPSecureStoreCredentialMapping                                  2230
Get-SPUserLicenseMapping                                               2230
Set-SPStateServiceApplication                                          2220
Get-SPStateServiceApplicationProxy                                     2210
Enable-SPBusinessDataCatalogEntity                                     2210
Revoke-SPBusinessDataCatalogMetadataObject                             2200
Clear-SPDistributedCacheItem                                           2190
Get-SPProcessAccount                                                   2190
Get-SPDesignerSettings                                                 2170
Get-SPRoutingMachinePool                                               2150
Copy-SPBusinessDataCatalogAclToChildren                                2150
Set-SPWorkflowConfig                                                   2120
Export-SPAppPackage                                                    2110
Get-SPAppDomain                                                        2100
Set-SPSessionStateService                                              2090
New-SPWorkManagementServiceApplication                                 2090
Dismount-SPStateServiceDatabase                                        2090
Set-SPPerformancePointServiceApplication                               2070
New-SPSecureStoreApplicationField                                      2070
Get-SPRoutingMachineInfo                                               2070
Add-SPThrottlingRule                                                   2070
Add-SPRoutingRule                                                      2060
Update-SPSecureStoreGroupCredentialMapping                             2040
Remove-SPUserLicenseMapping                                            2040
Uninstall-SPHelpCollection                                             2030
Get-SPRoutingRule                                                      2020
Resume-SPStateServiceDatabase                                          2000
Get-SPMobileMessagingAccount                                           2000
Set-SPSiteSubscriptionEdiscoveryHub                                    2000
Set-SPBrowserCustomerExperienceImprovementProgram                      2000
Set-SPStateServiceDatabase                                             1980
Disable-SPBusinessDataCatalogEntity                                    1980
Suspend-SPStateServiceDatabase                                         1980
Remove-SPContentDeploymentPath                                         1970
Set-SPSecureStoreApplication                                           1960
Set-SPStateServiceApplicationProxy                                     1960
Enable-SPWebApplicationHttpThrottling                                  1960
Set-SPContentDeploymentPath                                            1950
Remove-SPSocialItemByDate                                              1950
Remove-SPSiteUpgradeSessionInfo                                        1940
Disable-SPWebApplicationHttpThrottling                                 1940
Set-SPMobileMessagingAccount                                           1930
Remove-SPContentDeploymentJob                                          1930
Get-SPBrowserCustomerExperienceImprovementProgram                      1920
Clear-SPSiteSubscriptionBusinessDataCatalogConfig                      1910
Disable-SPSessionStateService                                          1900
Remove-SPSiteSubscriptionMetadataConfig                                1890
Clear-SPMetadataWebServicePartitionData                                1890
Uninstall-SPWebPartPack                                                1870
New-SPPerformancePointServiceApplicationProxy                          1840
Get-SPSiteSubscriptionMetadataConfig                                   1840
Export-SPSiteSubscriptionBusinessDataCatalogConfig                     1830
New-SPContentDeploymentJob                                             1790
Get-SPODataConnectionSettingMetadata                                   1730
Set-SPWorkManagementServiceApplication                                 1710
Set-SPRoutingMachineInfo                                               1700
Get-SPSiteSubscriptionEdiscoveryHub                                    1690
Get-SPSiteSubscriptionEdiscoverySearchScope                            1680
Set-SPRequestManagementSettings                                        1670
Get-SPUpgradeActions                                                   1660
New-SPUsageLogFile                                                     1660
Enable-SPAppAutoProvision                                              1650
Disable-SPHealthAnalysisRule                                           1650
Set-SPBingMapsKey                                                      1590
New-SPTranslationServiceApplication                                    1570
Disable-SPSingleSignOn                                                 1540
Get-SPPerformancePointServiceApplicationTrustedLocation                1480
Clear-SPSecureStoreCredentialMapping                                   1470
Set-SPSecureStoreServiceApplication                                    1420
Set-SPWordConversionServiceApplication                                 1370
Clear-SPSecureStoreDefaultProvider                                     1330
Set-SPSecureStoreDefaultProvider                                       1290
Remove-SPWordConversionServiceJobHistory                               1240
New-SPPerformancePointServiceApplicationTrustedLocation                1210
Remove-SPPerformancePointServiceApplicationTrustedLocation             1210
Remove-SPPerformancePointServiceApplication                            1200
Clear-SPPerformancePointServiceApplicationTrustedLocation              1190
Remove-SPPerformancePointServiceApplicationProxy                       1160
New-SPWorkManagementServiceApplicationProxy                            1080
New-SPPowerPointConversionServiceApplication                           1070
Set-SPTranslationServiceApplication                                    1020
New-SPPowerPointConversionServiceApplicationProxy                       994
Enable-SPHealthAnalysisRule                                             881
New-SPTranslationServiceApplicationProxy                                 50
Get-SPEnterpriseSearchResultItemType                                     50
Remove-SPODataConnectionSetting                                          49
Add-SPPluggableSecurityTrimmer                                           49
Get-SPBingMapsKey                                                        49
Get-SPAppSiteSubscriptionName                                            47
Get-SPEnterpriseSearchPropertyRule                                       47
Get-SPEnterpriseSearchHostController                                     47
Add-SPRoutingMachineInfo                                                 46
Get-SPEnterpriseSearchPropertyRuleCollection                             46
Get-SPPluggableSecurityTrimmer                                           46
Get-SPAppStateUpdateInterval                                             45
Set-SPSiteSubscriptionIRMConfig                                          45
Set-SPRoutingMachinePool                                                 45
Get-SPEnterpriseSearchLinksDatabase                                      45
Add-SPAppDeniedEndpoint                                                  45
Update-SPAppCatalogConfiguration                                         45
Clear-SPBusinessDataCatalogEntityNotificationWeb                         45
Disable-SPAppAutoProvision                                               45
Get-SPThrottlingRule                                                     44
Remove-SPRoutingMachineInfo                                              44
Get-SPIRMSettings                                                        43
Get-SPEnterpriseSearchContentEnrichmentConfiguration                     43
Set-SPThrottlingRule                                                     43
Get-SPEnterpriseSearchLinguisticComponentsStatus                         42
Set-SPODataConnectionSetting                                             42
Set-SPEnterpriseSearchLinksDatabase                                      42
Get-SPSiteSubscriptionIRMConfig                                          41
Get-SPScaleOutDatabaseLogEntry                                           41
Get-SPAppStateSyncLastRunTime                                            41
Add-SPScaleOutDatabase                                                   41
Install-SPEduSites                                                       41
Import-SPEnterpriseSearchPopularQueries                                  41
Get-SPAppScaleProfile                                                    41
Add-SPServerScaleOutDatabase                                             41
Export-SPScaleOutDatabaseTenantData                                      40
New-SPEnterpriseSearchResultItemType                                     40
Get-SPServerScaleOutDatabase                                             40
Get-SPBusinessDataCatalogEntityNotificationWeb                           40
Remove-SPPluggableSecurityTrimmer                                        40
Set-SPEnterpriseSearchCrawlLogReadPermission                             40
Get-SPScaleOutDatabase                                                   40
Get-SPEnterpriseSearchVssDataPath                                        40
Get-SPAppAutoProvisionConnection                                         39
Clear-SPScaleOutDatabaseTenantData                                       39
Remove-SPEnterpriseSearchContentEnrichmentConfiguration                  39
Set-SPInternalAppStateUpdateInterval                                     39
Get-SPScaleOutDatabaseInconsistency                                      39
Get-SPInternalAppStateSyncLastRunTime                                    38
Set-SPODataConnectionSettingMetadata                                     38
Get-SPInternalAppStateUpdateInterval                                     38
Get-SPScaleOutDatabaseDataState                                          38
Get-SPODataConnectionSetting                                             38
Move-SPDeletedSite                                                       38
New-SPBECWebServiceApplicationProxy                                      37
Set-SPAppStoreConfiguration                                              37
Clear-SPScaleOutDatabaseLog                                              37
Get-SPEnterpriseSearchCrawlLogReadPermission                             37
Get-SPOfficeStoreAppsDefaultActivation                                   37
Clear-SPServerScaleOutDatabaseDeletedDataSubRange                        35
Set-SPBusinessDataCatalogEntityNotificationWeb                           35
Clear-SPServerScaleOutDatabaseTenantData                                 35
Get-SPEnterpriseSearchServiceApplicationBackupStore                      35
Clear-SPScaleOutDatabaseDeletedDataSubRange                              35
Get-SPServerScaleOutDatabaseInconsistency                                35
Export-SPServerScaleOutDatabaseTenantData                                34
Remove-SPRoutingRule                                                     34
Get-SPServerScaleOutDatabaseLogEntry                                     34
Remove-SPEnterpriseSearchFileFormat                                      34
New-SPMarketplaceWebServiceApplicationProxy                              34
Set-SPAppManagementDeploymentId                                          34
Start-SPDiagnosticsSession                                               33
Set-SPAppStateUpdateInterval                                             33
Remove-SPThrottlingRule                                                  33
Set-SPWorkManagementServiceApplicationProxy                              33
Split-SPScaleOutDatabase                                                 33
Set-SPPowerPointConversionServiceApplication                             33
Get-SPServerScaleOutDatabaseDataState                                    33
Import-SPScaleOutDatabaseTenantData                                      33
Set-SPTranslationServiceApplicationProxy                                 32
Set-SPAppAutoProvisionConnection                                         32
Set-SPTrustedSecurityTokenIssuer                                         32
Copy-SPActivitiesToWorkflowService                                       32
Set-SPOfficeStoreAppsDefaultActivation                                   32
Remove-SPRoutingMachinePool                                              32
Stop-SPDiagnosticsSession                                                32
Set-SPRoutingRule                                                        31
Clear-SPServerScaleOutDatabaseLog                                        31
Remove-SPServerScaleOutDatabase                                          31
Remove-SPAppDeniedEndpoint                                               31
Set-SPScaleOutDatabaseDataSubRange                                       31
Remove-SPAppPrincipalPermission                                          30
Remove-SPTranslationServiceJobHistory                                    30
Remove-SPScaleOutDatabase                                                30
Get-SPAppStoreConfiguration                                              30
Upgrade-SPEnterpriseSearchServiceApplicationSiteSettings                 30
Set-SPAppScaleProfile                                                    30
Set-SPScaleOutDatabaseDataRange                                          29
Import-SPServerScaleOutDatabaseTenantData                                29
Split-SPServerScaleOutDatabase                                           29
Remove-SPEnterpriseSearchResultItemType                                  29
Restore-SPEnterpriseSearchServiceApplicationIndex                        28
Set-SPEnterpriseSearchLinguisticComponentsStatus                         28
Set-SPEnterpriseSearchPrimaryHostController                              28
Set-SPServerScaleOutDatabaseDataRange                                    27
New-SPEduClass                                                           27
Set-SPServerScaleOutDatabaseDataSubRange                                 26
Get-SPAppAcquisitionConfiguration                                        26
Move-SPEnterpriseSearchLinksDatabases                                    26
Get-SPWebApplicationAppDomain                                            26
Get-SPAppHostingQuotaConfiguration                                       25
Remove-SPEnterpriseSearchServiceApplicationSiteSettings                  25
Get-SPSecureStoreSystemAccount                                           25
Clear-SPAppDeniedEndpointList                                            25
Get-SPAppDeniedEndpointList                                              25
Remove-SPEnterpriseSearchCrawlLogReadPermission                          25
Set-SPEnterpriseSearchResultItemType                                     25
Add-SPSecureStoreSystemAccount                                           24
Remove-SPEnterpriseSearchTenantSchema                                    24
Get-SPAppDisablingConfiguration                                          24
Import-SPPerformancePointContent                                         24
Set-SPAppHostingQuotaConfiguration                                       23
Remove-SPSecureStoreSystemAccount                                        23
Get-SPBingMapsBlock                                                      23
Export-SPPerformancePointContent                                         23
New-SPUserSettingsProvider                                               22
Remove-SPEnterpriseSearchTenantConfiguration                             22
Remove-SPUserSettingsProvider                                            22
Remove-SPActivityFeedItems                                               22
Get-SPUserSettingsProvider                                               21
Get-SPUserSettingsProviderManager                                        21
Set-SPAppAcquisitionConfiguration                                        21
Set-SPAppDisablingConfiguration                                          21
Remove-SPWebApplicationAppDomain                                         21
Add-SPEduUser                                                            20
New-SPStateServiceApplication                                            20
Set-SPBingMapsBlock                                                      19
Add-SPEduClassMember                                                     19
Get-SPEduServiceSetting                                                  18
Move-SPSite                                                              17
Remove-SPEduClassMember                                                  16
New-SPWorkflowServiceApplicationProxy                                    16
Set-SPEduServiceSetting                                                  16
Get-SPEnterpriseSearchResultSource                                       14
New-SPBusinessDataCatalogServiceApplicationProxy                         13
New-SPEnterpriseSearchRankingModel                                       12
Set-SPAppSiteDomain                                                      12
New-SPOnlineApplicationPrincipalManagementServiceApplicationProxy        12
Restart-SPAppInstanceJob                                                 11
Remove-SPAlternateURL                                                    10
New-SPEnterpriseSearchResultSource                                       10
New-SPEnterpriseSearchContentEnrichmentConfiguration                      9
Update-SPHelp                                                             8
Get-SPTranslationThrottlingSetting                                        7
Set-SPTranslationThrottlingSetting                                        7
New-SPTrustedRootAuthority                                                7
Remove-SPWOPISuppressionSetting                                           7
Remove-SPSecureStoreApplication                                           7
Move-SPSocialComment                                                      7
New-SPWebApplicationExtension                                             6
Set-SPTopologyServiceApplicationProxy                                     5
Set-SPEnterpriseSearchResultSource                                        5
Remove-SPEnterpriseSearchResultSource                                     5
New-SPEnterpriseSearchMetadataMapping                                     4
New-SPEnterpriseSearchContentProcessingComponent                          4
New-SPTrustedServiceTokenIssuer                                           3
Set-SPEnterpriseSearchFileFormatState                                     3
Import-SPSiteSubscriptionBusinessDataCatalogConfig                        3
New-SPSecureStoreTargetApplication                                        3
New-SPEnterpriseSearchLinksDatabase                                       3
New-SPWordConversionServiceApplication                                    3
New-SPRequestManagementRuleCriteria                                       3

PS C:\>

Microsoft SQL Server 2014 PowerShell cmdlet popularity

$
0
0

If you follow the blog, you probably saw a little PowerShell script I published a while back to measure the popularity of the cmdlets in a certain module using a Bing search. As an example, that blog showed the popularity of the cmdlets in the SmbShare module.

Now I got curious about how the cmdlets in other modules would rank, so I spun up some Azure virtual machines to try some other modules. I decided to try the Microsoft SQL Server 2014 main module (named SQLPS).

image

The results are listed below:

PS C:\> .\PopularCmdlet.ps1 | Sort BingCount -Descending | FT -AutoSize

CmdletName                               BingCount
----------                               ---------
Invoke-Sqlcmd                                70700
Backup-SqlDatabase                           34100
Restore-SqlDatabase                          20300
Get-SqlDatabase                               7250
Invoke-PolicyEvaluation                       7170
Enable-SqlAlwaysOn                            5460
Add-SqlAvailabilityDatabase                   4230
Test-SqlAvailabilityGroup                     4050
Get-SqlInstance                               3850
Encode-SqlName                                3040
Set-SqlAvailabilityReplica                    2970
Test-SqlAvailabilityReplica                   2680
Join-SqlAvailabilityGroup                     2350
Switch-SqlAvailabilityGroup                   2330
Test-SqlDatabaseReplicaState                  2250
Set-SqlHADREndpoint                           2230
Set-SqlAvailabilityGroupListener              1930
Remove-SqlAvailabilityDatabase                1920
Convert-UrnToPath                             1790
Decode-SqlName                                1690
Disable-SqlAlwaysOn                           1370
Remove-SqlAvailabilityReplica                 1290
Set-SqlAvailabilityGroup                      1100
Suspend-SqlAvailabilityDatabase               1070
Resume-SqlAvailabilityDatabase                1050
Remove-SqlAvailabilityGroup                    889
Add-SqlAvailabilityGroupListenerStaticIp        50
New-SqlBackupEncryptionOption                   34
Get-SqlSmartAdmin                               34
Set-SqlSmartAdmin                               31
Get-SqlCredential                               28
Set-SqlCredential                               25
Remove-SqlCredential                            23
Set-SqlAuthenticationMode                       20
Test-SqlSmartAdmin                              18
Start-SqlInstance                               15
Stop-SqlInstance                                15
Set-SqlNetworkConfiguration                     10
Add-SqlFirewallRule                              9
Remove-SqlFirewallRule                           9
New-SqlAvailabilityGroup                         5
New-SqlAvailabilityGroupListener                 4
New-SqlHADREndpoint                              3
New-SqlCredential                                3
New-SqlAvailabilityReplica                       3

PS C:\>

New PowerShell cmdlets in Windows Server 2016 TP2 (compared to Windows Server 2012 R2)

$
0
0

 

1. State the problem

 

With the release of Windows Server 2016 TP2 a few weeks ago, I was wondering what new PowerShell cmdlets are now included (when you compare to Windows Server 2012 R2). However, the list of cmdlets is so long now that it is hard to spot the differences by hand.

However, there a cmdlet in PowerShell to show all the cmdlets available (Get-Command) and a little bit of programming would make it easy to find out what are the main differences. So I set out to collect the data and compare the list.

 

DISCLAIMER: As you probably know already, the Technical Preview is subject to change so all the information about Windows Server 2016 TP2 is preliminary and may not make it into the final product. Use with care, your mileage may vary, not available in all areas, some restrictions apply, professional PowerShell operator on a closed Azure VM course, do not attempt.

 

2. Gather the data

 

First, I needed the list of cmdlets from both versions of the operating system. That was actually pretty easy to gather, with a little help from Azure. I basically provisioned two Azure VM, one running Windows Server 2012 R2 and one running Windows Server 2016 Technical Preview 2 (yes, TP2 is now available in the regular Azure VM image gallery).

Second, I installed all of the Remote Server Administration Tools (RSAT) on both versions. That loads the PowerShell modules used for managing features that are not installed by default, like Failover Cluster or Storage Replica.

Finally, I ran a simple cmdlet to gather the list from Get-Command and save it to an XML file. This made it easier to put all the data I needed in a single place (my desktop machine running Windows 10 Insider Preview). Here's a summary of what it took:

  • Create WS 2012 R2 Azure VM
  • Install RSAT in the WS 2012 R2 VM
    • Get-WindowsFeature RSAT* | Install-WindowsFeature
  • Capture XML file with all the WS 2012 R2 cmdlet information
    • Get-Command | Select * | Export-CliXml C:\WS2012R2Cmdlets.XML
  • Create WS 2016 TP2 Azure VM
  • Install RSAT in the WS 2016 TP2 VM
    • Get-WindowsFeature RSAT* | Install-WindowsFeature

  • Capture XML file with all the WS 2016 TP2 cmdlet information
    • Get-Command | Select * | Export-CliXml C:\WS2016TP2Cmdlets.XML

 

3. Process the data

 

With the two XML files at hand, all I had left to do was to compare them to produce a good list of what's new. The first attempt resulted in a long list that was hard to understand, so I decided to do it module by module.

The code starts by creating a combined list of modules from both operating systems. Then it builds a dictionary of all cmdlets for a given module, assigning the value 1 if it's in WS 2012 R2, 2 if it's in WS 2016 TP2 and 3 if it's in both.

Then I would show the total number of cmdlets per module per OS, then number of new cmdlets and the actual list of new cmdlets. Since the goal was to publish this blog, I actually wrote the script to format the output as an HTML table. Quite handy :-).

 

4. Show the results

 

Finally, here is resulting table with all the new PowerShell cmdlets (by module) in Windows Server 2016 TP2, compared to Windows Server 2012. Enjoy!

 

ModuleNew CmdletsWS 2016 TP2
Cmdlets
WS 2012 R2
Cmdlets
03838
ActiveDirectory0147147
ADRMSAdmin02121
AppLocker055
Appx8146
+ Add-AppxVolume
+ Dismount-AppxVolume
+ Get-AppxDefaultVolume
+ Get-AppxVolume
+ Mount-AppxVolume
+ Move-AppxPackage
+ Remove-AppxVolume
+ Set-AppxDefaultVolume
BestPractices044
BitLocker01313
BitsTransfer088
BranchCache03232
CimCmdlets01414
CIPolicy110
+ ConvertFrom-CIPolicy
ClusterAwareUpdating01717
ConfigCI10100
+ Edit-CIPolicyRule
+ Get-CIPolicy
+ Get-CIPolicyInfo
+ Get-SystemDriver
+ Merge-CIPolicy
+ New-CIPolicy
+ New-CIPolicyRule
+ Remove-CIPolicyRule
+ Set-HVCIOptions
+ Set-RuleOption
Defender11110
+ Add-MpPreference
+ Get-MpComputerStatus
+ Get-MpPreference
+ Get-MpThreat
+ Get-MpThreatCatalog
+ Get-MpThreatDetection
+ Remove-MpPreference
+ Remove-MpThreat
+ Set-MpPreference
+ Start-MpScan
+ Update-MpSignature
DFSN02323
DFSR34542
+ Get-DfsrDelegation
+ Grant-DfsrDelegation
+ Revoke-DfsrDelegation
DhcpServer0121121
DirectAccessClientComponents01111
Dism44339
+ Add-WindowsCapability
+ Expand-WindowsCustomDataImage
+ Get-WindowsCapability
+ Remove-WindowsCapability
DnsClient01717
DnsServer21122101
+ Add-DnsServerClientSubnet
+ Add-DnsServerQueryResolutionPolicy
+ Add-DnsServerRecursionScope
+ Add-DnsServerZoneScope
+ Add-DnsServerZoneTransferPolicy
+ Disable-DnsServerPolicy
+ Enable-DnsServerPolicy
+ Get-DnsServerClientSubnet
+ Get-DnsServerQueryResolutionPolicy
+ Get-DnsServerRecursionScope
+ Get-DnsServerZoneScope
+ Get-DnsServerZoneTransferPolicy
+ Remove-DnsServerClientSubnet
+ Remove-DnsServerQueryResolutionPolicy
+ Remove-DnsServerRecursionScope
+ Remove-DnsServerZoneScope
+ Remove-DnsServerZoneTransferPolicy
+ Set-DnsServerClientSubnet
+ Set-DnsServerQueryResolutionPolicy
+ Set-DnsServerRecursionScope
+ Set-DnsServerZoneTransferPolicy
EventTracingManagement14140
+ Add-EtwTraceProvider
+ Get-AutologgerConfig
+ Get-EtwTraceProvider
+ Get-EtwTraceSession
+ New-AutologgerConfig
+ New-EtwTraceSession
+ Remove-AutologgerConfig
+ Remove-EtwTraceProvider
+ Remove-EtwTraceSession
+ Send-EtwTraceSession
+ Set-AutologgerConfig
+ Set-EtwTraceProvider
+ Set-EtwTraceSession
+ Start-AutologgerConfig
FailoverClusters28482
+ New-ClusterNameAccount
+ Update-ClusterFunctionalLevel
GroupPolicy02929
HgsClient11110
+ Export-HgsGuardian
+ Get-HgsAttestationBaselinePolicy
+ Get-HgsClientConfiguration
+ Get-HgsGuardian
+ Grant-HgsKeyProtectorAccess
+ Import-HgsGuardian
+ New-HgsGuardian
+ New-HgsKeyProtector
+ Remove-HgsGuardian
+ Revoke-HgsKeyProtectorAccess
+ Set-HgsClientConfiguration
Hyper-V26204178
+ Add-VMGroupMember
+ Add-VMSwitchTeamMember
+ Add-VMTPM
+ Disable-VMConsoleSupport
+ Enable-VMConsoleSupport
+ Get-VHDSet
+ Get-VHDSnapshot
+ Get-VMGroup
+ Get-VMHostCluster
+ Get-VMSwitchTeam
+ Get-VMTPM
+ Get-VMVideo
+ New-VMGroup
+ Optimize-VHDSet
+ Remove-VHDSnapshot
+ Remove-VMGroup
+ Remove-VMGroupMember
+ Remove-VMSwitchTeamMember
+ Rename-VMGroup
+ Set-VMHostCluster
+ Set-VMSwitchTeam
+ Set-VMTPM
+ Set-VMVideo
+ Start-VMTrace
+ Stop-VMTrace
+ Update-VMVersion
IISAdministration17170
+ Get-IISAppPool
+ Get-IISConfigCollectionItem
+ Get-IISConfigElement
+ Get-IISConfigSection
+ Get-IISConfigValue
+ Get-IISServerManager
+ Get-IISSite
+ New-IISConfigCollectionItem
+ New-IISSite
+ Remove-IISConfigCollectionItem
+ Remove-IISSite
+ Reset-IISServerManager
+ Set-IISConfigValue
+ Start-IISCommitDelay
+ Start-IISSite
+ Stop-IISCommitDelay
+ Stop-IISSite
International01818
iSCSI01313
IscsiTarget02828
ISE033
Kds066
Microsoft.PowerShell.Archive220
+ Compress-Archive
+ Expand-Archive
Microsoft.PowerShell.Core56055
+ Debug-Job
+ Enter-PSHostProcess
+ Exit-PSHostProcess
+ Get-PSHostProcessInfo
+ Register-ArgumentCompleter
Microsoft.PowerShell.Diagnostics055
Microsoft.PowerShell.Host022
Microsoft.PowerShell.Management48682
+ Clear-RecycleBin
+ Get-Clipboard
+ Get-ItemPropertyValue
+ Set-Clipboard
Microsoft.PowerShell.ODataUtils110
+ Export-ODataEndpointProxy
Microsoft.PowerShell.Security01313
Microsoft.PowerShell.Utility1110594
+ ConvertFrom-String
+ Convert-String
+ Debug-Runspace
+ Disable-RunspaceDebug
+ Enable-RunspaceDebug
+ Format-Hex
+ Get-Runspace
+ Get-RunspaceDebug
- GetStreamHash
+ New-Guid
+ New-TemporaryFile
+ Wait-Debugger
+ Write-Information
Microsoft.WSMan.Management01313
MMAgent055
MsDtc04141
NetAdapter46864
+ Disable-NetAdapterPacketDirect
+ Enable-NetAdapterPacketDirect
+ Get-NetAdapterPacketDirect
+ Set-NetAdapterPacketDirect
NetConnection022
NetEventPacketCapture02323
NetLbfo01313
NetNat01313
NetQos044
NetSecurity08585
NetSwitchTeam077
NetTCPIP03434
NetWNV01919
NetworkConnectivityStatus044
NetworkController1411410
+ Add-NetworkControllerNode
+ Clear-NetworkControllerNodeContent
+ Disable-NetworkControllerNode
+ Enable-NetworkControllerNode
+ Export-NetworkController
+ Get-NetworkController
+ Get-NetworkControllerCanaryConfiguration
+ Get-NetworkControllerCluster
+ Get-NetworkControllerCredential
+ Get-NetworkControllerDevice
+ Get-NetworkControllerDeviceGroupingTestConfiguration
+ Get-NetworkControllerDeviceGroups
+ Get-NetworkControllerDeviceGroupUsage
+ Get-NetworkControllerDeviceUsage
+ Get-NetworkControllerDiagnostic
+ Get-NetworkControllerDiscoveredTopology
+ Get-NetworkControllerExternalTestRule
+ Get-NetworkControllerFabricRoute
+ Get-NetworkControllerGoalTopology
+ Get-NetworkControllerInterface
+ Get-NetworkControllerInterfaceUsage
+ Get-NetworkControllerIpPool
+ Get-NetworkControllerIpPoolStatistics
+ Get-NetworkControllerIpSubnetStatistics
+ Get-NetworkControllerLogicalNetwork
+ Get-NetworkControllerLogicalSubnet
+ Get-NetworkControllerMonitoringService
+ Get-NetworkControllerNode
+ Get-NetworkControllerPhysicalHostInterfaceParameter
+ Get-NetworkControllerPhysicalHostParameter
+ Get-NetworkControllerPhysicalSwitchCpuUtilizationParameter
+ Get-NetworkControllerPhysicalSwitchInterfaceParameter
+ Get-NetworkControllerPhysicalSwitchMemoryUtilizationParameter
+ Get-NetworkControllerPhysicalSwitchParameter
+ Get-NetworkControllerPSwitch
+ Get-NetworkControllerPublicIpAddress
+ Get-NetworkControllerServer
+ Get-NetworkControllerServerInterface
+ Get-NetworkControllerSwitchBgpPeer
+ Get-NetworkControllerSwitchBgpRouter
+ Get-NetworkControllerSwitchConfig
+ Get-NetworkControllerSwitchNetworkRoute
+ Get-NetworkControllerSwitchPort
+ Get-NetworkControllerSwitchPortChannel
+ Get-NetworkControllerSwitchVlan
+ Get-NetworkControllerTopologyConfiguration
+ Get-NetworkControllerTopologyDiscoveryStatistics
+ Get-NetworkControllerTopologyLink
+ Get-NetworkControllerTopologyNode
+ Get-NetworkControllerTopologyTerminationPoint
+ Get-NetworkControllerTopologyValidationReport
+ Get-NetworkControllerVirtualInterface
+ Get-NetworkControllerVirtualNetworkUsage
+ Get-NetworkControllerVirtualPort
+ Get-NetworkControllerVirtualServer
+ Get-NetworkControllerVirtualServerInterface
+ Get-NetworkControllerVirtualSwitch
+ Get-NetworkControllerVirtualSwitchPortParameter
+ Import-NetworkController
+ Install-NetworkController
+ Install-NetworkControllerCluster
+ New-NetworkControllerCanaryConfiguration
+ New-NetworkControllerCredential
+ New-NetworkControllerDevice
+ New-NetworkControllerDeviceGroupingTestConfiguration
+ New-NetworkControllerDeviceGroups
+ New-NetworkControllerExternalTestRule
+ New-NetworkControllerInterface
+ New-NetworkControllerIpPool
+ New-NetworkControllerLogicalNetwork
+ New-NetworkControllerMonitoringService
+ New-NetworkControllerNodeObject
+ New-NetworkControllerPhysicalHostInterfaceParameter
+ New-NetworkControllerPhysicalHostParameter
+ New-NetworkControllerPhysicalSwitchCpuUtilizationParameter
+ New-NetworkControllerPhysicalSwitchInterfaceParameter
+ New-NetworkControllerPhysicalSwitchMemoryUtilizationParameter
+ New-NetworkControllerPhysicalSwitchParameter
+ New-NetworkControllerPSwitch
+ New-NetworkControllerPublicIpAddress
+ New-NetworkControllerServer
+ New-NetworkControllerServerInterface
+ New-NetworkControllerSwitchBgpPeer
+ New-NetworkControllerSwitchBgpRouter
+ New-NetworkControllerSwitchNetworkRoute
+ New-NetworkControllerSwitchPortChannel
+ New-NetworkControllerSwitchVlan
+ New-NetworkControllerTopologyLink
+ New-NetworkControllerTopologyNode
+ New-NetworkControllerTopologyTerminationPoint
+ New-NetworkControllerVirtualInterface
+ New-NetworkControllerVirtualPort
+ New-NetworkControllerVirtualServer
+ New-NetworkControllerVirtualServerInterface
+ New-NetworkControllerVirtualSwitch
+ New-NetworkControllerVirtualSwitchPortParameter
+ Remove-NetworkControllerCanaryConfiguration
+ Remove-NetworkControllerCredential
+ Remove-NetworkControllerDevice
+ Remove-NetworkControllerDeviceGroupingTestConfiguration
+ Remove-NetworkControllerDeviceGroups
+ Remove-NetworkControllerExternalTestRule
+ Remove-NetworkControllerFabricRoute
+ Remove-NetworkControllerInterface
+ Remove-NetworkControllerIpPool
+ Remove-NetworkControllerLogicalNetwork
+ Remove-NetworkControllerLogicalSubnet
+ Remove-NetworkControllerNode
+ Remove-NetworkControllerPhysicalSwitchCpuUtilizationParameter
+ Remove-NetworkControllerPhysicalSwitchMemoryUtilizationParameter
+ Remove-NetworkControllerPSwitch
+ Remove-NetworkControllerPublicIpAddress
+ Remove-NetworkControllerServer
+ Remove-NetworkControllerServerInterface
+ Remove-NetworkControllerSwitchBgpPeer
+ Remove-NetworkControllerSwitchBgpRouter
+ Remove-NetworkControllerSwitchNetworkRoute
+ Remove-NetworkControllerSwitchPortChannel
+ Remove-NetworkControllerSwitchVlan
+ Remove-NetworkControllerTopologyLink
+ Remove-NetworkControllerTopologyNode
+ Remove-NetworkControllerTopologyTerminationPoint
+ Remove-NetworkControllerVirtualInterface
+ Remove-NetworkControllerVirtualPort
+ Remove-NetworkControllerVirtualServer
+ Remove-NetworkControllerVirtualServerInterface
+ Remove-NetworkControllerVirtualSwitch
+ Repair-NetworkControllerCluster
+ Set-NetworkController
+ Set-NetworkControllerCluster
+ Set-NetworkControllerDiagnostic
+ Set-NetworkControllerFabricRoute
+ Set-NetworkControllerGoalTopology
+ Set-NetworkControllerLogicalSubnet
+ Set-NetworkControllerNode
+ Set-NetworkControllerSwitchConfig
+ Set-NetworkControllerSwitchPort
+ Set-NetworkControllerTopologyConfiguration
+ Start-NetworkControllerTopologyDiscovery
+ Uninstall-NetworkController
+ Uninstall-NetworkControllerCluster
NetworkLoadBalancingClusters03535
NetworkSwitchManager19190
+ Disable-NetworkSwitchEthernetPort
+ Disable-NetworkSwitchFeature
+ Disable-NetworkSwitchVlan
+ Enable-NetworkSwitchEthernetPort
+ Enable-NetworkSwitchFeature
+ Enable-NetworkSwitchVlan
+ Get-NetworkSwitchEthernetPort
+ Get-NetworkSwitchFeature
+ Get-NetworkSwitchGlobalData
+ Get-NetworkSwitchVlan
+ New-NetworkSwitchVlan
+ Remove-NetworkSwitchEthernetPortIPAddress
+ Remove-NetworkSwitchVlan
+ Restore-NetworkSwitchConfiguration
+ Save-NetworkSwitchConfiguration
+ Set-NetworkSwitchEthernetPortIPAddress
+ Set-NetworkSwitchPortMode
+ Set-NetworkSwitchPortProperty
+ Set-NetworkSwitchVlanProperty
NetworkTransition03434
NFS04242
Nps-6713
- Get-NpsRemediationServer
- Get-NpsRemediationServerGroup
- New-NpsRemediationServer
- New-NpsRemediationServerGroup
- Remove-NpsRemediationServer
- Remove-NpsRemediationServerGroup
PackageManagement10100
+ Find-Package
+ Get-Package
+ Get-PackageProvider
+ Get-PackageSource
+ Install-Package
+ Register-PackageSource
+ Save-Package
+ Set-PackageSource
+ Uninstall-Package
+ Unregister-PackageSource
PcsvDevice495
+ Clear-PcsvDeviceLog
+ Get-PcsvDeviceLog
+ Set-PcsvDeviceNetworkConfiguration
+ Set-PcsvDeviceUserPassword
Pester20200
+ AfterAll
+ AfterEach
+ Assert-MockCalled
+ Assert-VerifiableMocks
+ BeforeAll
+ BeforeEach
+ Context
+ Describe
+ Get-MockDynamicParameters
+ Get-TestDriveItem
+ In
+ InModuleScope
+ Invoke-Mock
+ Invoke-Pester
+ It
+ Mock
+ New-Fixture
+ Set-DynamicParameterVariables
+ Setup
+ Should
PKI01717
PnpDevice440
+ Disable-PnpDevice
+ Enable-PnpDevice
+ Get-PnpDevice
+ Get-PnpDeviceProperty
PowerShellGet11110
+ Find-Module
+ Get-InstalledModule
+ Get-PSRepository
+ Install-Module
+ Publish-Module
+ Register-PSRepository
+ Save-Module
+ Set-PSRepository
+ Uninstall-Module
+ Unregister-PSRepository
+ Update-Module
PrintManagement02222
PSDesiredStateConfiguration51712
+ Connect-DscConfiguration
+ Find-DscResource
+ Get-DscConfigurationStatus
+ Invoke-DscResource
+ Publish-DscConfiguration
PSDiagnostics01010
PSReadline550
+ Get-PSReadlineKeyHandler
+ Get-PSReadlineOption
+ Remove-PSReadlineKeyHandler
+ Set-PSReadlineKeyHandler
+ Set-PSReadlineOption
PSScheduledJob01616
PSWorkflow022
PSWorkflowUtility011
RemoteAccess14121107
+ Add-BgpRouteAggregate
+ Add-VpnSstpProxyRule
+ Clear-BgpRouteFlapDampening
+ Disable-BgpRouteFlapDampening
+ Enable-BgpRouteFlapDampening
+ Get-BgpRouteAggregate
+ Get-BgpRouteFlapDampening
+ Get-VpnSstpProxyRule
+ New-VpnSstpProxyRule
+ Remove-BgpRouteAggregate
+ Remove-VpnSstpProxyRule
+ Set-BgpRouteAggregate
+ Set-BgpRouteFlapDampening
+ Set-VpnSstpProxyRule
RemoteDesktop57873
+ Export-RDPersonalSessionDesktopAssignment
+ Get-RDPersonalSessionDesktopAssignment
+ Import-RDPersonalSessionDesktopAssignment
+ Remove-RDPersonalSessionDesktopAssignment
+ Set-RDPersonalSessionDesktopAssignment
ScheduledTasks01919
SecureBoot055
ServerCore022
ServerManager077
ServerManagerTasks01111
ShieldedVMDataFile330
+ Import-ShieldingDataFile
+ New-VolumeIDQualifier
+ Protect-ShieldingDataFile
ShieldedVMTemplate110
+ Protect-ServerVHDX
SmbShare03535
SmbWitness033
SoftwareInventoryLogging01111
StartScreen033
Storage32140108
+ Block-FileShareAccess
+ Clear-StorageDiagnosticInfo
+ Debug-FileShare
+ Debug-StorageSubSystem
+ Disable-PhysicalDiskIdentification
+ Disable-StorageDiagnosticLog
+ Enable-PhysicalDiskIdentification
+ Enable-StorageDiagnosticLog
+ Get-DedupProperties
+ Get-DiskSNV
+ Get-DiskStorageNodeView
+ Get-FileShare
+ Get-FileShareAccessControlEntry
+ Get-StorageAdvancedProperty
+ Get-StorageDiagnosticInfo
+ Get-StorageEnclosureSNV
+ Get-StorageEnclosureStorageNodeView
+ Get-StorageFaultDomain
+ Get-StorageFileServer
+ Grant-FileShareAccess
+ New-FileShare
+ New-StorageFileServer
+ Optimize-StoragePool
+ Remove-FileShare
+ Remove-StorageFileServer
+ Revoke-FileShareAccess
+ Set-FileShare
+ Set-StorageFileServer
+ Start-StorageDiagnosticLog
+ Stop-StorageDiagnosticLog
+ Stop-StorageJob
+ Unblock-FileShareAccess
StorageQoS660
+ Get-StorageQoSFlow
+ Get-StorageQoSPolicy
+ Get-StorageQoSVolume
+ New-StorageQoSPolicy
+ Remove-StorageQoSPolicy
+ Set-StorageQoSPolicy
StorageReplica11110
+ Get-SRGroup
+ Get-SRPartnership
+ New-SRGroup
+ New-SRPartnership
+ Remove-SRGroup
+ Remove-SRPartnership
+ Set-SRGroup
+ Set-SRPartnership
+ Suspend-SRGroup
+ Sync-SRGroup
+ Test-SRTopology
TLS374
+ Disable-TlsCipherSuite
+ Enable-TlsCipherSuite
+ Get-TlsCipherSuite
TroubleshootingPack022
TrustedPlatformModule01111
UpdateServices41612
+ Add-WsusDynamicCategory
+ Get-WsusDynamicCategory
+ Remove-WsusDynamicCategory
+ Set-WsusDynamicCategory
UserAccessLogging01414
VpnClient01919
Wdac01212
WebAdministration08080
Whea022
WindowsDeveloperLicense033
WindowsErrorReporting033
WindowsSearch022

 

5. Share the code

 

For those wondering about the script I used to compile the results, here it goes.

#
# Enumerating all the modules from both OS versions
#

# Load XML files into memory: $Files[0] and $Files[1]

$Files
= ( (Import-Clixml"C:\WS2012R2Cmdlets.XML"),
           (Import-Clixml"C:\WS2016TP2Cmdlets.XML") )

# Create empty dictionary for modules


$ModuleDict
= @{}

# Loop through the two files to gather module info

$Files
|% {
  $_|GroupModuleName|SortName|% {
    $Module=$_.Name

    # If found, increase count. If not, add to dictionary


    If
($ModuleDict.ContainsKey($Module)) {
      $ModuleDict.$Module++
    } Else {
      $ModuleDict.Add($Module,1)
    } # End If

  }
# End Import

}
# End $Files

#
# Enumerate the cmdlets in every module
#

# Add the HTML table header

Write-Host
"<table border=1><tr><td><b>Module</b></td><td>New Cmdlets</td><td>WS 2016 TP2</td><td>WS 2012 R2</td></tr>"

# Loop through the modules in the dictionary

$ModuleDict
.GetEnumerator() |SortName|% {

  # Initialize variables for a new module


  $Module
=$_.Name
  $VersionCount= (0,0)
  $CmdletDict= @{}

  # Loop through the two files, filtering by module

  0
..1|% {

    $WSVersion
=$_
    $Files[$_]|?ModuleName-eq$Module|% {

      $Cmdlet
=$_.Name

      # Count cmdlets by module for each OS version

      $VersionCount
[$WSVersion]++

      # Increase per-cmdlet value by 1 (WS2012R2) or by 2 (WS2016TP2)
      # If cmdlet exists in both OSes, value will be 3

      If
($CmdletDict.ContainsKey($Cmdlet)) {
        $CmdletDict.$Cmdlet+= ($WSVersion+1)
      } Else {
        $CmdletDict.Add($Cmdlet, ($WSVersion+1))
      } # End If

    }
# End %

  }
# End 0..1

  #
  # Output the list of cmdlets that changed in every module
  #

  # Copy data to single variables for easy use with Write-Host
  
  $WS0
=$VersionCount[0]
  $WS1=$VersionCount[1]
  $Dif=$WS1-$WS0
  $CrLf="<BR>"+[char]10+[char]13

  # Write HTML table row with module summary information

  Write-Host
"<tr><td><b>$Module</b></td><td align=`"right`">$Dif</td><td align=`"right`">$WS1</td><td align=`"right`">$WS0</td></tr>" 

  # If there are cmdlets in the module

  If
($CmdletDict.Count -gt0) {

    # Gather all new and removed cmdlets in a variable

    $CmdletList
=""
    $CmdletDict.GetEnumerator() |? {$_.Value -eq2-or$_.Value -eq1} |SortName|% {

      # 1 means removed cmdlet. 2 means new cmdlet

      $Name
=$_.Name
      If ($_.Value -eq1) {
        $CmdletList+="- $Name"+$CrLf
      } else {
        $CmdletList+="+ $Name"+$CrLf
      } # End If

    }
# End Enumerator

    # If new or removed exist, write another HTML table row

    If
($CmdletList-ne"") {
      Write-Host"<tr><td colspan=4>$CmdletList</td></tr>"
    } # End If

  }
# End if

} # End Module

# Write HTML table end. All done.

Write-Host
"</table>"

 

Using PowerShell and Excel PivotTables to understand the files on your disk

$
0
0

 

Introduction

I am a big fan of two specific technologies that usually don’t get mentioned together: PowerShell and Excel PivotTables. It started when I was explaining PivotTables to someone and the main issue I had was finding a good set of example data that is familiar to everyone. That’s when it hit me. People using a computer have tons of files stored in their local disks and most don’t have a clue about those files. That’s the perfect example!

So I set out to gather the steps to gather information about your local files and extract the most information about it.

 

Step 1 – List the questions you need to answer

To start, here are a few questions you might have about the files in your local hard drive:

  • Which folder is storing the most files or using up the most space in your local disk?
  • What kind of data (pictures, music, video) is using the most space in your local disk?
  • What is the average size of the pictures you took this year?
  • How much of the files in your local disk was created in the last 30 days? Or this year?
  • Which day of the week do you create the most new pictures? Or PowerPoint presentations?

Now you could write a PowerShell script to answer any of those questions. It would in itself be a great programming exercise, but some would be quite tricky to code. However, those questions are just the tip of the iceberg. Given that dataset, you could come up with many, many more. So the point is that you would use Excel PivotTables to explore the data set and come up with the answers while interacting with it.

 

Step 2 – Gather the required raw data

In any work with PivotTables and BI (Business Inteligence) in general, you need to identify the raw data that you can use to produce the answers to your questions. As you problably already figured out, we’ll use PowerShell to query the file system and extract that data. Using the Get-ChildItem (more commonly known by its alias: DIR), you can get information about each folder and file on the disk.

Now with possibly hundreds of thousands of files, you want to make sure you gather only the necessary data. That will make it faster to obtain and will give Excel less data to chew on, which is always a good thing.Here’s what you could use (running as an administrator), to get information:

Dir C:\ -Recurse | Select FullName, Extension, Length, CreationTime, Attributes

Next, you want to make sure you transform into into a format that Excel can consume. Luckly, PowerShell has a cmdlet to transform data into Comma-Separated Values, also known as CSV. You need to also include something to avoid any permission errors while accessing the data and output the results to a file, so we can load it into Excel. Here’s the final command line:

Dir \ -Recurse -ErrorAction SilentlyContinue | Select FullName, Extension, Length, CreationTime, Attributes | ConvertTo-Csv  -NoTypeInformation | Out-File C:\AllFiles.csv

That command will take several minutes to run, depending on the number of files on your disk, the speed of the disk and the speed of your computer. The resulting file can get quite big as well. In my case, it took a few minutes and the resulting file size was 135,359,136 bytes (or around 130MB).

 

Step 3 – Load into Excel and build the right table

With the AllFiles.csv file available, we can now load the raw data in Excel and start working with it. Just open Excel (I’m using Excel 2016 Preview) and load the CSV file. When importing, make sure to select “Delimited” in the first page of the wizard and check the “comma” checkbox in the second page.

clip_image001

clip_image002

Excel loaded the data and I ended up with 412,012 rows (including one row for the header). However the formating was a little lacking…

clip_image003

clip_image004

Next, I applied a format each column for best results. You want to format the Length to a number with comma separators and no decimals. To do that, select the third column and click to format as a number.

clip_image005

You can also use the same process to format the fourth column with a more interesting date format.

clip_image006

Here’s what it looks like at this point.

clip_image007

Last but not least, you want to freeze the top row of the spreadsheet and format the whole think as a table.

clip_image008

clip_image009

clip_image010

Here’s the final look for this phase:

clip_image011

 

Step 4 – Add fields that will help with your questions

While you have most of the data you need readily acessible, it helps to add to your table some additional fields. You could add those to your original PowerShell query, but Excel is probably better equipped to generate those extra columns on the fly.

Also, you might notice the need to add those only after you have played with the data a bit with Excel. That will also give you a chance to brush up on your Excel formula skills. In this example, we will add the following fields to the table:

  • CreatedYear – Year the file was created. Formula =YEAR([@CreationTime])
  • CreatedDays – Days since the file was created. Formula =TODAY()-[@CreationTime]
  • CreatedDow – Day of the week the file was created. Formula = =WEEKDAY([@CreationTime])
  • IsFolder – True if the item is folder, not a file. Formula =NOT(ISERROR(FIND("Directory",[@Attributes])))
  • TopFolder – First folder in the file name. Formula = =IF(ISERROR(FIND("\",[@FullName],4)),"C:\",LEFT([@FullName],FIND("\",[@FullName],4)))

Just insert the extra columns (right click column, click insert) and fill in the title and the formula. Excel will apply the formula to all cells in that column automatically. You will need to reformat the columns for CreatedYear, CreatedDays, CreatedDow to show as regular numbers, without any decimals.

clip_image012

 

Step 5 – Create a Pivot Table

With all the columns in place, you should proceed and create the Pivot Table. Just click on a cell at the table and choose Pivot Table under the “Insert” tab.

clip_image013

That will create an empty PivotTable with all the fields on the table available to you.

clip_image014

Now you just have to drag the fields to one of the four white boxes below the field list: Filters, Columns, Rows or Values. You will have options on how things are summarized (count, sum, average), how to format the data, how fields are sorted, etc.

To start, you can drag TopFolder to the Rows and Length to the Values. You should make adjustments to the “Count of Length” under Values to format as a number with no decimals.

clip_image015

You will also need to change the “More sort options” of the “TopFolder” field to sort on descending order by “Sum of Length”.

clip_image016

To avoid counting folders, you could add the IsFolder field to the filter box and then click on cell B1 to change the filter to false. Here’s what you should get: A sorted list of top-level folders with the number of files in each.

clip_image017

Simply by changing the settings in “Count of Length” to make it a sum, you get the list of top folders with the total size in bytes for each one:

clip_image018

Those two will answer the first question on our list: Which folder is storing the most files or using up the most space in your local disk?

 

Step 6 – Tweak the PivotTable to your heart’s content

Now you have everything you need to slice and dice the data, answering any of the questions posed at the beginning of this blog. Here are a few examples, with specific comments for each one. Top 20 extensions for all the disk. Start with dragging extension to the rows, then filter by TOP 10 and adjust:

clip_image019

So I have a lot used by programs (DLL, EXE), but also a fair amount of bytes used by music (WMA), videos (MP4) and pictures (JPG).

clip_image020

Next I could filter only to files under the C:\Users\ folder, which would exclude the operating system. After that, PowerPoint files jump up to number 4, right after music, videos and pictures.

clip_image021

If I want to look at the size of a particular kind of file, I would filter by that extension and add a few things to the values. To look at statistics of pictures I took this year, I dragged length to the values a few times and adjusted to do count, sum and max. I also moved the “∑ Values” from Columns to Rows. I finished by adding Created Year to the filters and selecting 2015.

clip_image022

Lastly, I looked at the the breakdown of files by the day of the week they were created. I was looking at the total number of files created in a given day of the week, broken down by the top 20 file extension. I had filters for user files only and restricted it also to files created in 2015. I also removed the Grand totals for this one. Apparently I did a lot of my file creation this year on this computer on Thursdays and Fridays.

clip_image023

Finally, here’s a more complex scenario showing a total of files, capacity, oldest year and largest size. I played with changing the default name of the values, which makes the labels a bit more readable. There’s also multiple items in the rows, creating a hieararchy. I’ll let you figure out how to get to this particular view.

clip_image024

 

Conclusion

I hope this post was a good example of all the things you can do with Excel PivotTables. In my view, this gets really powerful if you have an interesting data set to play with, which PowerShell and the file system were glad to provide for us. Let me know if you found this useful and share your experience with file/folder statistics, gathering data sets with PowerShell and PivotTables.

For my next data set, I was thinking about gathering some data about e-mails. There’s another thing that everyone has in large quantities…

Drive Performance Report Generator - PowerShell script using DiskSpd by Arnaud Torres

$
0
0

Arnaud Torres is a Senior Premier Field Engineer at Microsoft in France who sent me the PowerShell script below called "Drive Performance Report Generator".

He created the script to test a wide range of profiles in one run to allow people to build a baseline of their storage using DiskSpd.EXE.

The script is written in PowerShell v1 and was tested on a Windows Server 2008 SP2 (really!), Windows Server 2012 R2 and Windows 10.

It displays results in real time, is highly documented and creates a text report which can be imported as CSV in Excel.

 

Thanks to Arnaud for sharing!

 

----------------------

 

# Drive performance Report Generator

# by Arnaud TORRES

# Microsoft provides script, macro, and other code examples for illustration only, without warranty either expressed or implied, including but not

# limited to the implied warranties of merchantability and/or fitness for a particular purpose. This script is provided 'as is' and Microsoft does not

# guarantee that the following script, macro, or code can be used in all situations.

# Script will stress your computer CPU and storage, be sure that no critical workload is running

 

# Clear screen

Clear

 

write-host "DRIVE PERFORMANCE REPORT GENERATOR" -foregroundcolor green

write-host "Script will stress your computer CPU and storage layer (including network if applciable !), be sure that no critical workload is running" -foregroundcolor yellow

write-host "Microsoft provides script, macro, and other code examples for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. This script is provided 'as is' and Microsoft does not guarantee that the following script, macro, or code can be used in all situations." -foregroundcolor darkred

"   "

"Test will use all free space on drive minus 2 GB !"

"If there are less than 4 GB free test will stop"

 

# Disk to test

$Disk = Read-Host 'Which disk would you like to test ? (example : D:)'

# $Disk = "D:"

if ($disk.length -ne 2){"Wrong drive letter format used, please specify the drive as D:"

                         Exit}

if ($disk.substring(1,1) -ne ":"){"Wrong drive letter format used, please specify the drive as D:"

                         Exit}

$disk = $disk.ToUpper()

 

# Reset test counter

$counter = 0

 

# Use 1 thread / core

$Thread = "-t"+(Get-WmiObject win32_processor).NumberofCores

 

# Set time in seconds for each run

# 10-120s is fine

$Time = "-d1"

 

# Outstanding IOs

# Should be 2 times the number of disks in the RAID

# Between  8 and 16 is generally fine

$OutstandingIO = "-o16"

 

# Disk preparation

# Delete testfile.dat if it exists

# The test will use all free space -2GB

 

$IsDir = test-path -path "$Disk\TestDiskSpd"

$isdir

if ($IsDir -like "False"){new-item -itemtype directory -path "$Disk\TestDiskSpd\"}

# Just a little security, in case we are working on a compressed drive ...

compact /u /s $Disk\TestDiskSpd\

 

$Cleaning = test-path -path "$Disk\TestDiskSpd\testfile.dat"

if ($Cleaning -eq "True")

{"Removing current testfile.dat from drive"

  remove-item $Disk\TestDiskSpd\testfile.dat}

 

$Disks = Get-WmiObject win32_logicaldisk

$LogicalDisk = $Disks | where {$_.DeviceID -eq $Disk}

$Freespace = $LogicalDisk.freespace

$FreespaceGB = [int]($Freespace / 1073741824)

$Capacity = $freespaceGB - 2

$CapacityParameter = "-c"+$Capacity+"G"

$CapacityO = $Capacity * 1073741824

 

if ($FreespaceGB -lt "4")

{

       "Not enough space on the Disk ! More than 4GB needed"

       Exit

}

 

write-host " "

$Continue = Read-Host "You are about to test $Disk which has $FreespaceGB GB free, do you wan't to continue ? (Y/N) "

if ($continue -ne "y" -or $continue -ne "Y"){"Test Cancelled !!"

                                        Exit}

 

"   "

"Initialization can take some time, we are generating a $Capacity GB file..."

"  "

 

 

# Initialize outpout file

$date = get-date

 

# Add the tested disk and the date in the output file

"Disque $disk, $date" >> ./output.txt

 

# Add the headers to the output file

“Test N#, Drive, Operation, Access, Blocks, Run N#, IOPS, MB/sec, Latency ms, CPU %" >> ./output.txt

 

# Number of tests

# Multiply the number of loops to change this value

# By default there are : (4 blocks sizes) X (2 for read 100% and write 100%) X (2 for Sequential and Random) X (4 Runs of each)

$NumberOfTests = 64

 

"  "

write-host "TEST RESULTS (also logged in .\output.txt)" -foregroundcolor yellow

 

# Begin Tests loops

 

# We will run the tests with 4K, 8K, 64K and 512K blocks

(4,8,64,512) | % { 

$BlockParameter = ("-b"+$_+"K")

$Blocks = ("Blocks "+$_+"K")

 

# We will do Read tests and Write tests

  (0,100) | % {

      if ($_ -eq 0){$IO = "Read"}

      if ($_ -eq 100){$IO = "Write"}

      $WriteParameter = "-w"+$_

 

# We will do random and sequential IO tests

  ("r","si") | % {

      if ($_ -eq "r"){$type = "Random"}

      if ($_ -eq "si"){$type = "Sequential"}

      $AccessParameter = "-"+$_

 

# Each run will be done 4 times

  (1..4) | % {

     

      # The test itself (finally !!)

         $result = .\diskspd.exe $CapacityPArameter $Time $AccessParameter $WriteParameter $Thread $OutstandingIO $BlockParameter -h -L $Disk\TestDiskSpd\testfile.dat

     

      # Now we will break the very verbose output of DiskSpd in a single line with the most important values

      foreach ($line in $result) {if ($line -like "total:*") { $total=$line; break } }

      foreach ($line in $result) {if ($line -like "avg.*") { $avg=$line; break } }

      $mbps = $total.Split("|")[2].Trim()

      $iops = $total.Split("|")[3].Trim()

      $latency = $total.Split("|")[4].Trim()

      $cpu = $avg.Split("|")[1].Trim()

      $counter = $counter + 1

 

      # A progress bar, for the fun

      Write-Progress -Activity ".\diskspd.exe $CapacityPArameter $Time $AccessParameter $WriteParameter $Thread $OutstandingIO $BlockParameter -h -L $Disk\TestDiskSpd\testfile.dat" -status "Test in progress" -percentComplete ($counter / $NumberofTests * 100)

     

      # Remove comment to check command line ".\diskspd.exe $CapacityPArameter $Time $AccessParameter $WriteParameter $Thread -$OutstandingIO $BlockParameter -h -L $Disk\TestDiskSpd\testfile.dat"

     

      # We output the values to the text file

      “Test $Counter,$Disk,$IO,$type,$Blocks,Run $_,$iops,$mbps,$latency,$cpu"  >> ./output.txt

 

      # We output a verbose format on screen

      “Test $Counter, $Disk, $IO, $type, $Blocks, Run $_, $iops iops, $mbps MB/sec, $latency ms, $cpu CPU"

}

}

}

}

 

Viewing all 122 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>