In a previous post I forgot to include the PowerShell code for Get-FullDomainAccount. Sorry about that.
Here it is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
$env:USERDOMAIN = "<your domain>" <# .SYNOPSIS Ensures that the given domain account also has the domain prefix. For example, if the -DomainAccount is "IUSR_AbcXyz" the "<your domain>\IUSR_AbcXyz" would most likely be returned. The domain is pulled from the current users domain, $env:USERDOMAIN. If -Environment is provided, this will also run the -DomainAccount through Get-EnvironmentDomainAccount to replace any environment specific information. .LINK Get-EnvironmentDomainAccount Used to apply environment specific value to the domain account .EXAMPLE $result = Get-FullDomainAccount -DomainAccount "IUSR_AbcXyz" $result -eq "<your domain>\IUSR_AbcXyz" #> Function Get-FullDomainAccount { [ CmdletBinding ()] Param ( [ Parameter ( Mandatory = $true )] [string] $DomainAccount , [string ] $Environment = " " ) $accountName = $DomainAccount; if($Environment -ne "") { $accountName = Get-EnvironmentDomainAccount -Environment $Environment -DomainAccount $DomainAccount; } if($accountName -match " ApplicationPoolIdentity ") { $accountName = " IIS AppPool\ $accountName " } if($accountName -match " LocalSystem ") { $accountName = " $( $env:COMPUTERNAME )\ $accountName " } if($accountName -notmatch " \\ ") { $accountName = $env:USERDOMAIN + " \" + $accountName ; } return $accountName ; } |
0 comments:
Post a Comment