This cmdlet/function takes a required parameter ‘Session’, which is of type ‘System.Management.Automation.Runspaces.PSSession’ that can be obtained via New-PSSession cmdlet of the ‘Microsoft.PowerShell.Core’ module.

It also takes 2 optional parameters that serve to filter its output:

-Layer3 parameter takes either ‘IPv4’ or ‘IPv6’ values or both, and will output only the records that match this criteria

-Layer4 parameter takes either ‘TCP’ or ‘UDP’ values or both, and will output only the records that match this criteria

Searches files with txt extension in the current folder and its subfolders, outputs the findings in HTML report and saves the file list in the $PiiFiles variable. That can be exported to CSV as in:

$PiiFiles | Export-Csv .\piilist1.csv -NoTypeInformation

Management of PII (Personally Identifiable Information) has always been a source of concern. PII includes information such as social security numbers and credit card numbers. Companies may have policies to regulate how they’re handled, and perhaps require encrypting the files where they’re stored. IT may be asked to audit or report on any files containing PII. This script does just that. The script is implemented as a function the SBTools module available on the Microsoft Script Center Repository.

Get-PII function uses EnahncedHTML2 functions by Don Jones who graciously agreed to have them included in SBTools module.

Asset information, such as Internet Protocol (IP) or Media Access Control (MAC) address or other host-specific persistent static identifier that consistently links to a particular person or small, well defined group of people

Information identifying personally owned property, such as vehicle registration number or title number and related information

Information about an individual that is linked or linkable to one of the above (e.g., date of birth, place of birth, race, religion, weight, activities, geographical indicators, employment information, medical information, education information, financial information).

This script searches and reports only on social security numbers and credit card numbers. It can be modified to detect additional PII patterns. Feel free to post a comment if you’d like to see more patterns added..

To search on a set of folders and report on files containing PII use a command like:

Get-PII “txt”,”csv”,”doc?” “D:\Sandbox”,”\\Server1\Install\Script?”

This searches the folder d:\sandbox and \\Server1\Install\script? for files with extensions txt, csv, and doc?, and compiles an HTML report of any files including PII.

-Keep [<SwitchParameter>]
This is a switch. When selected, the function will export the imported module(s)
locally under “C:\Program Files\WindowsPowerShell\Modules” if it’s in the PSModulePath,
otherwise, it will export it to the default path “$home\Documents\WindowsPowerShell\Modules”
– Note 1: Exported modules and their commands can be used directly from any PS instance
after a module has been exported with the -keep switch
– Note 2: Even though a module has been exported locally, everytime you try to use one of
its commands, PS will start an implicit remoting session to the server where the
module was imported from.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).

NOTES
Function by Sam Boutros
Requires PS 3.0
v1.0 – 08/17/2014
Although we need to eventually run:
Remove-PSSession -Session $Session
We cannot do that in the function as we’ll lose the imported session commands
Two things to consider:
1. The session will be automatically removed when the PS console is closed
2. If in the parent script that’s using this function a blanket Remove-PSSession
command is run, like:
Get-PSSession | Remove-PSSession
We’ll lose this session and its commands, which could cripple the parent script

This example imports all the commands from the ActiveDirectory module from the DC01 server
So, in this PS console instance we can use AD commands like Get-ADComputer without the need
to install AD features, tools, or PS modules on this computer!

————————– EXAMPLE 2 ————————–

C:\PS>Import-SessionCommands SQLPS,Storage V-2012R2-SQL1 -Verbose

This example imports all the commands from the PSSQL and Storage modules from the MySQLServer
server into the current PS instance

To install it, extract the .rar file, and run install-SBTools.ps1 in the folder where you extracted the .rar file.

Get-SBRDPSession:

This is a function to get RDP sessions on one or more computers. It returns object collection, each corresponding to a session. Object properties: ComputerName, UserName, SessionName, ID, and State. ID refers to RDP session ID. State refers to RDP session State

Parameters:

This function accepts the following 2 parameters:

Parameter ComputerName
If absent, function assumes localhost.

Parameter State
Filters result by one or more States (Disconnected, Connected, Active, Listen)
Valid options are:
Disc
Conn
Active
Listen

Examples:

Get-SBRDPSession -ComputerName xHost15 -State Disc | FT

This example lists disconnected RDP sessions on the computer xHost16 in table format.

Sample output:

Get-SBRDPSession -state Active,Disc | FT

This example lists RDP sessions on the local machine, and returns those with State Active or Disc in table format.

Sample output:

Get-SBRDPSession xhost11,xhost12 | FT

This example lists RDP sesions on the computers xHost11 and xHost12 and outputs the result in table format.

Sample output:

Get-SBRDPSession (Get-Content .\computers.txt) Disc -Verbose | FT

This example reads a computer list from the file .\computers.txt and displays disconnected sessions

To install it, extract the .rar file, and run install-SBTools.ps1 in the folder where you extracted the .rar file.

Test-SBDisk:

This is a function to test disk IO performance. It uses other functions in the SBTools module like Log and New-SBSeed.

This function tests disk IO performance by creating random files on the target disk and measuring IO performance. It leaves 2 files in the WorkFolder:

A log file that lists script progress, and

a CSV file that has a record for each testing cycle

Parameters:

This function accepts 5 parameters:

Parameter WorkFolder This is where the test and log files will be created. Must be on a local drive. UNC paths are not supported. The function will create the folder if it does not exist The function will fail if it’s run in a security context that cannot create files and folders in the WorkFolder Example: c:\support

Parameter MaxSpaceToUseOnDisk Maximum Space To Use On Disk (in Bytes) Example: 10GB, or 115MB or 1234567890

.Parameter Threads This is the maximum number of concurrent copy processes the script will spawn. Maximum is 16. Default is 1.

Parameter Cycles The function generates random files in a subfolder under the WorkFolder. When the total WorkSubFolder size reaches 90% of MaxSpaceToUseOnDisk, the script deletes all test files and starts over. This is a cycle. Each cycle stats are recorded in the CVS and log files Default value is 3.

Parameter SmallestFile Order of magnitude of the smallest file. The function uses the following 9 orders of magnitude: (10KB,100KB,1MB,10MB,100MB,1GB,10GB,100GB,1TB) referred to as 0..8 For example, SmallestFile value of 4 tells the script to use smallest file size of 100MB The script uses a variable: LargestFile, it’s selected to be one order of magnitude below MaxSpaceToUseOnDisk To see higher IOPS select a high SmallestFile value Default value is 4 (100MB). If the SmallestFile is too high, the script adjusts it to be one order of magnitude below LargestFile