Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save current changes #308

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
function Get-SdnAuditLogSetting {
<#
.SYNOPSIS
Retrieves the audit log settings for the Network Controller
.PARAMETER NcUri
Specifies the Uniform Resource Identifier (URI) of the network controller that all Representational State Transfer (REST) clients use to connect to that controller.
.PARAMETER Credential
Specifies a user account that has permission to perform this action. The default is the current user.
#>

[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[Uri]$NcUri,

[Parameter(Mandatory = $false)]
[System.Management.Automation.PSCredential]
[System.Management.Automation.Credential()]
$Credential = [System.Management.Automation.PSCredential]::Empty
)

$object = [PSCustomObject]@{
Enabled = $false
OutputDirectory = $null
}

# verify that the environment we are on supports at least v3 API and later
# as described in https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-ncnbi/dc23b547-9ec4-4cb3-ab20-a6bfe01ddafb
$currentRestVersion = (Get-SdnResource -NcUri $NcUri.AbsoluteUri -Resource 'Discovery' -Credential $NcRestCredential).properties.currentRestVersion
[int]$currentRestVersionInt = $currentRestVersion.Replace('V','').Replace('v','').Trim()
if ($currentRestVersionInt -lt 3) {
"Auditing requires API version 3 or later. Network Controller supports version {0}" -f $currentRestVersionInt | Trace-Output -Level:Warning
return
}

# check to see that auditing has been enabled
$auditSettingsConfig = Get-SdnResource -NcUri $NcUri.AbsoluteUri -Resource 'AuditingSettingsConfig' -ApiVersion $currentRestVersion -Credential $NcRestCredential
if ([string]::IsNullOrEmpty($auditSettingsConfig.properties.outputDirectory)) {
return $object
}
else {
$object.Enabled = $true
$object.OutputDirectory = $auditSettingsConfig.properties.outputDirectory

return $object
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

function Get-SdnAuditLog {
<#
.SYNOPSIS
Expand Down Expand Up @@ -37,23 +36,10 @@ function Get-SdnAuditLog {
$Credential = [System.Management.Automation.PSCredential]::Empty
)

# verify that the environment we are on supports at least v3 API and later
# as described in https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-ncnbi/dc23b547-9ec4-4cb3-ab20-a6bfe01ddafb
$currentRestVersion = (Get-SdnResource -NcUri $NcUri.AbsoluteUri -Resource 'Discovery' -Credential $NcRestCredential).properties.currentRestVersion
[int]$currentRestVersionInt = $currentRestVersion.Replace('V','').Replace('v','').Trim()
if ($currentRestVersionInt -lt 3) {
"Auditing requires API version 3 or later. Network Controller supports version {0}" -f $currentRestVersionInt | Trace-Output -Level:Warning
return
}

# check to see that auditing has been enabled
$auditSettingsConfig = Get-SdnResource -NcUri $NcUri.AbsoluteUri -Resource 'AuditingSettingsConfig' -ApiVersion $currentRestVersion -Credential $NcRestCredential
if ([string]::IsNullOrEmpty($auditSettingsConfig.properties.outputDirectory)) {
"Audit logging is not enabled" | Trace-Output
return
}
else {
"Audit logging location: {0}" -f $auditSettingsConfig.properties.outputDirectory | Trace-Output
$auditSettings = Get-SdnAuditLogSetting -NcUri $NcUri -Credential $NcRestCredential
if ($auditSettings.Enabled -eq $false) {
"Audit logs are not enabled" | Trace-Output
return $null
}

# if $ComputerName was not specified, then attempt to locate the servers within the SDN fabric
Expand Down
Loading