ADAuditTasks

Syntax

Convert-NmapXMLToCSV [-InputXml] <String> [[-AttachmentFolderPath] <String>] [<CommonParameters>]

Parameters

Name Alias Description Required? Pipeline Input Default Value
-InputXml A string containing the full path to the Nmap XML file that needs to be converted. true true (ByPropertyName)
-AttachmentFolderPath The output folder path where the converted CSV file will be saved.
Default location is "C:\temp\NmapXMLToCSV".
false true (ByPropertyName) C:\temp\NmapXMLToCSV

Note

Make sure the input Nmap XML file is properly formatted and contains the necessary information for the conversion to work correctly.

Examples

EXAMPLE 1
Convert-NmapXMLToCSV -InputXml "C:\path\to\nmap.xml" -AttachmentFolderPath "C:\path\to\output"
This example will convert the contents of "C:\path\to\nmap.xml" into a CSV file and save it in "C:\path\to\output".

Top of page

Links

Syntax

Get-ADActiveUserAudit [[-Enabled] <Boolean>] [[-DaysInactive] <Int32>] [[-AttachmentFolderPath] <String>] [[-Report]] [<CommonParameters>]

Parameters

Name Alias Description Required? Pipeline Input Default Value
-Enabled If "$false", will also search disabled users. false true (ByPropertyName) True
-DaysInactive How far back in days to look for sign ins. Outside of this window, users are considered "Inactive" false true (ByPropertyName) 90
-AttachmentFolderPath Default path is C:\temp\ADActiveUserAudit.
This is the folder where attachments are going to be saved.
false true (ByValue) C:\temp\ADActiveUserAudit
-Report Add report output as csv to DirPath directory. false true (ByPropertyName) False

Outputs

The output type is the type of the objects that the cmdlet emits.

  • ADAuditTasksUser

Note

Outputs to C:\temp\ADActiveUserAudit by default. For help type: help Get-ADActiveUserAudit -ShowWindow

Examples

EXAMPLE 1
Get-ADActiveUserAudit
EXAMPLE 2
Get-ADActiveUserAudit -Report -Verbose
EXAMPLE 3
Get-ADActiveUserAudit -Enabled $false -DaysInactive 30 -AttachmentFolderPath "C:\temp\MyNewFolderName" -Report -Verbose

Top of page

Links

Syntax

Get-ADHostAudit [-HostType] <String> [[-DaystoConsiderAHostInactive] <Int32>] [[-Report]] [[-AttachmentFolderPath] <String>] [-Enabled <Boolean>] [<CommonParameters>]

Get-ADHostAudit [-OSType] <String> [[-DaystoConsiderAHostInactive] <Int32>] [[-Report]] [[-AttachmentFolderPath] <String>] [-Enabled <Boolean>] [<CommonParameters>]

Parameters

Name Alias Description Required? Pipeline Input Default Value
-HostType Specifies the type of hosts to search for. Valid values are WindowsServers, WindowsWorkstations, and Non-Windows. true true (ByValue)
-OSType Specifies the operating system to search for. There is no need to add wildcards. true true (ByValue)
-DaystoConsiderAHostInactive Specifies the number of days to consider a host as inactive. false true (ByPropertyName) 90
-Report Saves a CSV report to the specified directory. false true (ByPropertyName) False
-AttachmentFolderPath Specifies the directory where attachments will be saved. false false C:\temp\ADHostAudit
-Enabled If set to $false, the function will also search for disabled computers. false true (ByPropertyName) True

Outputs

The output type is the type of the objects that the cmdlet emits.

  • System.Management.Automation.PSObject

Note

By default, output is saved to C:\temp\ADHostAudit. For more information, type: Get-Help Get-ADHostAudit -ShowWindow

Examples

EXAMPLE 1
Get-ADHostAudit -HostType WindowsServers -Report -Verbose
EXAMPLE 2
Get-ADHostAudit -HostType WindowsWorkstations -Report -Verbose
EXAMPLE 3
Get-ADHostAudit -HostType "Non-Windows" -Report -Verbose
EXAMPLE 4
Get-ADHostAudit -OSType "2008" -DirPath "C:\Temp\" -Report -Verbose

Top of page

Links

Syntax

Get-ADUserLogonAudit [-SamAccountName] <Object> [<CommonParameters>]

Parameters

Name Alias Description Required? Pipeline Input Default Value
-SamAccountName Identity, UserName, Account Specifies the SamAccountName of the user account to be checked for the most recent LastLogon timestamp. true true (ByValue)

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • A SamAccountName string representing the user account to be checked.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • A DateTime object representing the most recent LastLogon timestamp for the specified user account.

Note

This function is designed to be run on the primary domain controller, but it can be run on any domain controller in the environment. It requires the Active Directory PowerShell module and appropriate permissions to read user account data. The function may take some time to complete if the Active Directory environment is large or the domain controllers are geographically distributed.

Examples

EXAMPLE 1
Get-ADUserLogonAudit -SamAccountName "jdoe"
Retrieves the most recent LastLogon timestamp for the user account with the SamAccountName
"jdoe" from all domain controllers in the Active Directory environment.

Top of page

Links

Syntax

Get-ADUserPrivilegeAudit [[-AttachmentFolderPath] <String>] [[-Report]] [<CommonParameters>]

Parameters

Name Alias Description Required? Pipeline Input Default Value
-AttachmentFolderPath Specifies the path of the folder where you want to save attachments. The default path is C:\temp\ADUserPrivilegeAudit. false true (ByValue) C:\temp\ADUserPrivilegeAudit
-Report Adds report output as CSV to the directory specified by AttachmentFolderPath. false true (ByPropertyName) False

Outputs

The output type is the type of the objects that the cmdlet emits.

  • System.Management.Automation.PSObject[] System.String System.Object[]

Note

This function requires the ActiveDirectory module and the desktop version of Powershell. Import-Module ADAuditTasks -UseWindowsPowershell in powershell core.

Examples

EXAMPLE 1
Get-ADUserPrivilegeAudit -Verbose
Gets the reports as three separate objects. To instantiate variables with the objects, provide three objects on the left side of the assignment:
Example: $a,$b,$c = Get-ADUserPrivilegeAudit -Verbose
The objects will be populated with privileged groups, AD extended rights, and possible service accounts, respectively.
EXAMPLE 2
Get-ADUserPrivilegeAudit -Report -Verbose
Returns three reports to the default folder, C:\temp\ADUserPrivilegeAudit, in a single zip file.

Top of page

Links

Syntax

Get-ADUserWildCardAudit [[-Enabled] <Boolean>] [[-DaysInactive] <Int32>] -WildCardIdentifier <String> [[-AttachmentFolderPath] <String>] [[-Report]] [<CommonParameters>]

Parameters

Name Alias Description Required? Pipeline Input Default Value
-Enabled If "$false", will also search disabled users. false true (ByPropertyName) True
-DaysInactive How far back in days to look for sign ins. Outside of this window, users are considered "Inactive" false true (ByPropertyName) 90
-WildCardIdentifier The search string to look for in the name of the account. Case does not matter. Do not add a
wildcard (*) as it will do this automatically.
true true (ByPropertyName)
-AttachmentFolderPath Default path is C:\temp\ADUserWildCardAudit. This is the folder where attachments are going to be saved. false true (ByValue) C:\temp\ADUserWildCardAudit
-Report Add report output as csv to AttachmentFolderPath directory. false true (ByPropertyName) False

Outputs

The output type is the type of the objects that the cmdlet emits.

  • ADAuditTasksUser

Note

This function requires the ActiveDirectory module.

Examples

EXAMPLE 1
Get-ADUserWildCardAudit -WildCardIdentifier "svc" -Report -Verbose
Searches for all user accounts that are named like the search string "svc".

Top of page

Links

Parameters

Name Alias Description Required? Pipeline Input Default Value
-DateFormat None Enter the date format string. false true (ByValue)

Syntax

Get-HostTag [-PhysicalOrVirtual] <String> [-Prefix] <String> [-SystemOS] <String> [-DeviceFunction] <String> [[-HostCount] <Int32>] [<CommonParameters>]

Parameters

Name Alias Description Required? Pipeline Input Default Value
-PhysicalOrVirtual Tab through selections to add 'P' or 'V' for physical or virtual to host tag. true true (ByPropertyName)
-Prefix Enter the 2-3 letter prefix. Good for prefixing company initials, locations, or other. true true (ByPropertyName)
-SystemOS Use tab to cycle through the following options:
"Cisco ASA", "Android", "Apple IOS",
"Dell Storage Center", "MACOSX",
"Dell Power Edge", "Embedded", "Embedded Firmware",
"Cisco IOS", "Linux", "Qualys", "Citrix ADC (Netscaler)",
"Windows Thin Client", "VMWare",
"Nutanix", "TrueNas", "FreeNas",
"ProxMox", "Windows Workstation", "Windows Server",
"Windows Server Core", "Generic OS", "Generic HyperVisor"
true true (ByPropertyName)
-DeviceFunction Use tab to cycle through the following options:
"Application Server", "Backup Server", "Directory Server",
"Email Server", "Firewall", "FTP Server",
"Hypervisor", "File Server", "NAS File Server",
"Power Distribution Unit", "Redundant Power Supply", "SAN Appliance",
"SQL Server", "Uninteruptable Power Supply", "Web Server",
"Management", "Blade Enclosure", "Blade Enclosure Switch",
"SAN specific switch", "General server/Network switch", "Generic Function Device"
true true (ByPropertyName)
-HostCount Enter a number from 1 to 999 for how many hostnames you'd like to create. false true (ByPropertyName) 1

Outputs

The output type is the type of the objects that the cmdlet emits.

  • System.Object[] System.String[]

Note

Additional information about the function, usage tips, etc.

Examples

EXAMPLE 1
Get-HostTag -PhysicalOrVirtual Physical -Prefix "CSN" -SystemOS 'Windows Server' -DeviceFunction 'Application Server' -HostCount 5
    CSN-PWSVAPP001
    CSN-PWSVAPP002
    CSN-PWSVAPP003
    CSN-PWSVAPP004
    CSN-PWSVAPP005
This creates the name of the host under 15 characters and numbers them. Prefix can be 2-3 characters.

Top of page

Links

Syntax

Get-NetworkAudit [[-Ports] <Int32[]>] [-LocalSubnets] [[-ThrottleLimit] <Int32>] [-NoHops] [-AddService] [-Report] [-ScanOnPingFail] [-WhatIf] [-Confirm] [<CommonParameters>]

Get-NetworkAudit [[-Ports] <Int32[]>] [-Computers] <String[]> [[-ThrottleLimit] <Int32>] [-NoHops] [-AddService] [-Report] [-ScanOnPingFail] [-WhatIf] [-Confirm] [<CommonParameters>]

Parameters

Name Alias Description Required? Pipeline Input Default Value
-Ports Specifies the ports to scan. If not provided, the function uses default ports:
"21", "22", "23", "25", "53", "67", "68", "80", "443",
"88", "464", "123", "135", "137", "138", "139",
"445", "389", "636", "514", "587", "1701",
"3268", "3269", "3389", "5985", "5986"

To specify ports, provide an integer or an array of integers. Example: "22", "80", "443"
false true (ByPropertyName)
-LocalSubnets Scans subnets connected to the local device. It will not scan outside of the hosting device's subnet. true true (ByPropertyName) False
-Computers Scans a single host or an array of hosts using subnet ID in CIDR notation, IP address, NETBIOS name, or FQDN in double quotes.
Example: "10.11.1.0/24", "10.11.2.0/24"
true true (ByPropertyName)
-ThrottleLimit Specifies the number of concurrent threads. Default: 32. false true (ByPropertyName) 32
-NoHops Prevents scans across a gateway. false true (ByPropertyName) False
-AddService Includes the service name associated with each port in the output. false true (ByPropertyName) False
-Report Generates a report in the C:\temp folder if specified. false true (ByPropertyName) False
-ScanOnPingFail Scans a host even if ping fails. false true (ByPropertyName) False
-WhatIf wi false false
-Confirm cf false false

Outputs

The output type is the type of the objects that the cmdlet emits.

  • System.Management.Automation.PSObject

Examples

EXAMPLE 1
Get-NetworkAudit -Report
Generates a report of the network audit results in the C:\temp folder.

Top of page

Links

Syntax

Get-QuickPing [-IPRange] <Array> [[-TTL] <Int32>] [[-BufferSize] <Int32>] [[-Count] <Int32>] [<CommonParameters>]

Parameters

Name Alias Description Required? Pipeline Input Default Value
-IPRange Specifies a range of IP addresses to ping. Can be a string with a single IP address. true false
-TTL Specifies the Time-to-Live (TTL) value to use for the ping. The default value is 128. false false 128
-BufferSize Specifies the size of the buffer to use for the ping. The default value is 16. false false 16
-Count Specifies the number of times to send the ping request. The default value is 1. false false 1

Examples

EXAMPLE 1
Get-QuickPing -IPRange 192.168.1.1
Performs a quick ping on the IP address 192.168.1.1 with a TTL of 128 and returns an
array of IP addresses that responded to the ping and an array of IP addresses that
failed to respond.
EXAMPLE 2
Get-QuickPing -IPRange "192.168.1.1", "192.168.1.2", "192.168.1.3"
Performs a quick ping on the IP addresses 192.168.1.1, 192.168.1.2, and 192.168.1.3 with
a TTL of 128 and returns an array of IP addresses that responded to the ping and an array
of IP addresses that failed to respond.

Top of page

Links

Syntax

Get-WebCertAudit [-Url] <String[]> [<CommonParameters>]

Parameters

Name Alias Description Required? Pipeline Input Default Value
-Url The URL of the web server. true true (ByPropertyName)

Outputs

The output type is the type of the objects that the cmdlet emits.

  • PSCustomObject Returns a PowerShell custom object with the following properties: Subject: The subject of the certificate. Thumbprint: The thumbprint of the certificate. Expires: The expiration date of the certificate.

Note

This function requires access to the target web server over port 443 (HTTPS).

Examples

EXAMPLE 1
Get-WebCert -Url "https://www.example.com"
This example retrieves the certificate information for the web server at https://www.example.com.

Top of page

Links

Syntax

Join-CSVFile [-CSVFilePaths] <String[]> [[-AttachmentFolderPath] <String>] [<CommonParameters>]

Parameters

Name Alias Description Required? Pipeline Input Default Value
-CSVFilePaths An array of strings containing the file paths of the CSV files to be merged. true true (ByPropertyName)
-AttachmentFolderPath The output folder path where the merged CSV file will be saved. Default location is "C:\temp\MergedCSV". false true (ByPropertyName) C:\temp\MergedCSV

Outputs

The output type is the type of the objects that the cmdlet emits.

  • None. The function outputs a merged CSV file to the specified folder.

Note

Make sure the input CSV files have the same headers and formatting for the function to work properly.

Examples

EXAMPLE 1
Join-CSVFiles -CSVFilePaths @("C:\path\to\csv1.csv", "C:\path\to\csv2.csv") -AttachmentFolderPath "C:\path\to\output.csv"
This example will merge the contents of "C:\path\to\csv1.csv" and "C:\path\to\csv2.csv" into a single CSV file and save it in "C:\path\to\output.csv".

Top of page

Links

Syntax

Merge-ADAuditZip [[-FilePaths] <String[]>] [[-MaxFileSize] <Int32>] [[-OutputFolder] <String>] [-OpenDirectory] [<CommonParameters>]

Parameters

Name Alias Description Required? Pipeline Input Default Value
-FilePaths Specifies an array of file paths to be merged into a single compressed ZIP file. false false
-MaxFileSize Specifies the maximum file size (in bytes) for the output ZIP file. The default
value is 24 MB.
false false 25165824
-OutputFolder Specifies the output folder for the merged compressed ZIP file. The default folder
is C:\temp.
false false C:\temp
-OpenDirectory Specifies an optional switch to open the directory of the merged compressed ZIP
file after creation.
false false False

Note

This function will split the output file into multiple parts if the maximum file size is exceeded. If the size exceeds the limit, a new ZIP file will be created with an incremental number added to the file name. This function may or may not work with various types of input.

Examples

EXAMPLE 1
$workstations = Get-ADHostAudit -HostType WindowsWorkstations -Report
$servers = Get-ADHostAudit -HostType WindowsServers -Report
$nonWindows = Get-ADHostAudit -HostType "Non-Windows" -Report
Merge-ADAuditZip -FilePaths $workstations, $servers, $nonWindows
This example combines three audit reports for Windows workstations, Windows servers, and non-Windows hosts into a single compressed ZIP file.
EXAMPLE 2
Merge-ADAuditZip -FilePaths C:\AuditReports\Report1.csv,C:\AuditReports\Report2.csv -MaxFileSize 50MB -OutputFolder C:\MergedReports -OpenDirectory
This example merges two audit reports into a single compressed ZIP file with a maximum file size of 50 MB, an output folder of C:\MergedReports, and opens the directory of the merged compressed ZIP file after creation.

Top of page

Links

Syntax

Merge-NmapToADHostAudit -ADAuditCsv <String> -NmapCsv <String> [[-AttachmentFolderPath] <String>] [<CommonParameters>]

Parameters

Name Alias Description Required? Pipeline Input Default Value
-ADAuditCsv The path to the Active Directory host audit CSV file. true true (ByPropertyName)
-NmapCsv The path to the Nmap network audit CSV file. true true (ByPropertyName)
-AttachmentFolderPath The output folder path where the merged CSV file and unmatched Nmap data CSV file will
be saved. Default location is "C:\temp\NmapToADHostAudit".
false true (ByPropertyName) C:\temp\NmapToADHostAudit

Note

Make sure the input CSV files have the correct headers and formatting for the function to work properly.

Examples

EXAMPLE 1
Merge-NmapToADHostAudit -ADAuditCsv "C:\path\to\ADAudit.csv" -NmapCsv "C:\path\to\NmapAudit.csv" -AttachmentFolderPath "C:\path\to\output"
This example will merge the Active Directory host audit data in "C:\path\to\ADAudit.csv" with the Nmap network audit data in "C:\path\to\NmapAudit.csv" and save the merged data to a new CSV file in "C:\path\to\output". Unmatched Nmap data will also be saved to a separate CSV file in the same output folder.

Top of page

Links

Syntax

Send-AuditEmail -AttachmentFiles <String[]> [-SMTPServer <String>] [-Port <Int32>] [-UserName <String>] [-SSL] [-From <String>] [-To <String>] [-Subject <String>] [-Body <String>] [-Pass <SecureString>] [<CommonParameters>]

Send-AuditEmail -AttachmentFiles <String[]> [-SMTPServer <String>] [-Port <Int32>] [-UserName <String>] [-SSL] [-From <String>] [-To <String>] [-Subject <String>] [-Body <String>] -Function <String> -FunctionApp <String> -Token <String> -CertificateThumbprint <String> [<CommonParameters>]

Parameters

Name Alias Description Required? Pipeline Input Default Value
-AttachmentFiles The full filepath to the zip you are sending:
-AttachmentFiles "C:\temp\ADHostAudit\2023-01-04_03.45.14_Get-ADHostAudit_AD.CONTOSO.COM.Servers.zip"

The Audit reports output this filename if the "-Report" switch is used allowing it to be nested in this parameter
for ease of automation.
true true (ByPropertyName)
-SMTPServer The SMTP Server address. For example: "smtp.office365.com" false false
-Port The following ports can be used to send email:
"993", "995", "587", "25"
false true (ByPropertyName) 0
-UserName The Account authorized to send email via SMTP. From parameter is usually the same. false false
-SSL Switch to ensure SSL is used during transport. false false False
-From This is who the email will appear to originate from. This is either the same as the UserName,
or, if delegated, access to an email account the Username account has delegated permissions to send for.
Link:
https://learn.microsoft.com/en-us/microsoft-365/admin/add-users/give-mailbox-permissions-to-another-user?view=o365-worldwide
false false
-To This is the mailbox who will be the recipient of the communication. false false
-Subject The subject is automatically populated with the name of the function that ran the script,
as well as the domain and hostname.

If you specify subject in the parameters, it will override the default with your subject.
false false "$($script:MyInvocation.MyCommand.Name -replace '\..*') report ran for $($env:USERDOMAIN) on host $($env:COMPUTERNAME)."
-Body The body of the message, pre-populates with the same data as the subject line. Specify body text
in the function parameters to override.
false false "$($script:MyInvocation.MyCommand.Name -replace '\..*') report ran for $($env:USERDOMAIN) on host $($env:COMPUTERNAME)."
-Pass Takes a SecureString as input. The password must be added to the command by using:
-Pass (Read-Host -AsSecureString)
You will be promted to enter the password for the UserName parameter.
false false
-Function If you are using the optional function feature and created a password retrieval function,
this is the name of the function in Azure AD that accesses the vault.
true false
-FunctionApp If you are using the optional function feature, this is the name of the function app in Azure AD. true false
-Token If you are using the optional function feature, this is the api token for the specific function.
Ensure you are using the "Function Key" and NOT the "Host Key" to ensure access is only to the specific funtion.
true false
-CertificateThumbprint API key for the Azure Function App true false

Examples

EXAMPLE 1
Send-AuditEmail -SMTPServer "smtp.office365.com" -Port 587 -UserName "Username@contoso.com" `
-From "Username@contoso.com" -To "user@anothercompany.com" -Pass (Read-Host -AsSecureString) -AttachmentFiles "$(Get-ADActiveUserAudit -Report)" -SSL
This will automatically send the report zip via email to the parameters specified. There is no cleanup of files. Please cleanup the directory of zip's if neccessary.
EXAMPLE 2
Send-AuditEmail -SMTPServer "smtp.office365.com" -Port 587 -UserName "Username@contoso.com" `
-From "Username@contoso.com" -To "user@anothercompany.com" -AttachmentFiles "$(Get-ADActiveUserAudit -Report)" -FunctionApp "MyVaultFunctionApp" `
-Function "MyClientSpecificFunction" -Token "ABCDEF123456" -SSL
This will automatically send the report zip via email to the parameters specified. There is no cleanup of files. Please cleanup the directory of zip's if neccessary.

Top of page

Links

Syntax

Submit-FTPUpload [[-FTPUserName] <String>] [[-Password] <SecureString>] [[-FTPHostName] <String>] [[-Protocol] <String>] [[-FTPSecure] <String>] [[-SshHostKeyFingerprint] <String[]>] [[-LocalFilePath] <String[]>] [[-RemoteFTPPath] <String>] [<CommonParameters>]

Parameters

Name Alias Description Required? Pipeline Input Default Value
-FTPUserName Specifies the username to use when connecting to the FTP server. false false
-Password Specifies the password to use when connecting to the FTP server. false false
-FTPHostName Specifies the name of the FTP server to connect to. false false
-Protocol Specifies the protocol to use when connecting to the FTP server. The default value is SFTP. false false Sftp
-FTPSecure Specifies the level of security to use when connecting to the FTP server. The default value is None. false false None
-SshHostKeyFingerprint Specifies the fingerprint of the SSH host key to use when connecting to the FTP server. This parameter is mandatory with SFTP and SCP. false false
-LocalFilePath Specifies the local path to the file to upload to the FTP server. false false
-RemoteFTPPath Specifies the remote path to upload the file to on the FTP server. false false

Outputs

The output type is the type of the objects that the cmdlet emits.

  • The function does not generate any output.

Note

This function requires the WinSCP PowerShell module.

Examples

EXAMPLE 1
Submit-FTPUpload -FTPUserName "username" -Password $Password -FTPHostName "ftp.example.com" -Protocol "Sftp" -FTPSecure "None" -SshHostKeyFingerprint "00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff" -LocalFilePath "C:\temp\file.txt" -RemoteFTPPath "/folder"
In this example, the Submit-FTPUpload function is used to upload a file to an FTP server. The FTP server is named "ftp.example.com" and the file to upload is located at "C:\temp\file.txt". The SSH host key fingerprint is also provided.

Top of page

Links