Skip to content
Open
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
2 changes: 1 addition & 1 deletion Grafana/Alloy/Scripts/Install-Alloy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
.\Install-Alloy.ps1

.NOTES
Version : 1.0.0.25340
Version : 1.0.1.26130
#>

Import-Module "$PSScriptRoot\Install-Alloy.psm1"
Expand Down
17 changes: 12 additions & 5 deletions Grafana/Alloy/Scripts/Install-Alloy.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Functions for installing Grafana Alloy.

.NOTES
Version : 1.0.0.25340
Version : 1.0.1.26130
#>

#region Internal Functions
Expand Down Expand Up @@ -155,7 +155,16 @@ function Test-ServiceUser {
)

process {
(New-Object DirectoryServices.DirectoryEntry "",$($ServiceUser.UserName),$($ServiceUser.GetNetworkCredential().Password)).psbase.name -ne $null
Add-Type -AssemblyName System.DirectoryServices.AccountManagement

$contextType = [System.DirectoryServices.AccountManagement.ContextType]::Domain
$domainName, $Username = $ServiceUser.Username -split '\\'
$password = $ServiceUser.GetNetworkCredential().Password

$principalContext = New-Object System.DirectoryServices.AccountManagement.PrincipalContext($contextType, $domainName)

$isValid = $principalContext.ValidateCredentials($userName, $password)
$isValid
}
}

Expand Down Expand Up @@ -332,9 +341,7 @@ function Set-LocalSecurityPolicy {

process {
Write-Output "Verifying Local Security Policy for $Username"

$FQDN = (Get-ADDomainController -Discover -DomainName $Username.substring(0, $Username.IndexOf("\"))).Domain
$UserSID = (Get-ADUser -ErrorAction Stop -Server "$FQDN" -Identity $Username.substring($Username.IndexOf("\") + 1)).SID
$UserSID = (New-Object System.Security.Principal.NTAccount($Username.substring($Username.IndexOf("\") + 1))).Translate([System.Security.Principal.SecurityIdentifier]).Value

$secEditConfigurationExport = Export-LocalSecurityPolicy

Expand Down