$AppName = "MyAppName"
#Open the store
$AzStore = New-Object -COMobject AzRoles.AzAuthorizationStore
#Access the App
$MyApp = $AzStore.OpenApplication($AppName)
任何人都可以帮我完成这个。
答案 0 :(得分:0)
您可能会发现此示例很有用:
# This internal function will download latest NetSqlAzMan.dll from NuGet (if necessary)
# and import it into current runspace.
# You can manually download installation package from netsqlazman.codeplex.com and
# Add-Type it directly instead of this function
function _DownloadAndImportLatestNetSqlAzManDll
{
$DownloadUrl = 'https://api.nuget.org/packages/netsqlazman-x86.3.6.0.15.nupkg'
$LocalDir = Join-Path $env:TEMP 'NetSqlAzManx86'
$LocalNupkg = Join-Path $LocalDir 'netsqlazman-x86.3.6.0.15.nupkg'
$DllPath = Join-Path $LocalDir 'lib\net40\NetSqlAzMan.dll'
if (-not (Test-Path $LocalDir)) {
New-Item -Path $LocalDir -ItemType Directory -Force | Out-Null
}
if (-not (Test-Path $LocalNupkg)) {
Invoke-WebRequest -Uri $DownloadUrl -Method Get -OutFile $LocalNupkg | Out-Null
}
if (-not (Test-Path $DllPath)) {
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory($LocalNupkg, $LocalDir)
}
Add-Type -Path $DllPath
}
_DownloadAndImportLatestNetSqlAzManDll
# Initialization:
$ConnectionString = 'Server=MySQLServerHostName; Database=NetSqlAzManStorage; Integrated Security=True'
$AppStoreName = 'MyAppStoreName'
$AppName = 'MyAppName'
$AppGroupName = 'MyAppGroupName'
$AzStorage = New-Object NetSqlAzMan.SqlAzManStorage($ConnectionString)
$AzStore = $AzStorage.GetStore($AppStoreName)
$AzApp = $AzStore.GetApplication($AppName)
# Example usage:
$UserName = ''
$Members = $AzApp.GetApplicationGroup($AppGroupName).GetApplicationGroupAllMembers()
"Members of application group $AppGroupName are:"
foreach ($Member in $Members)
{
$Member.GetMemberInfo([ref] $UserName) | Out-Null
"User SID: $($Member.SID.StringValue)"
"User Display Name: $UserName"
}
# See NetSqlAzMan API reference: http://netsqlazman.codeplex.com/downloads/get/348377
# Cleanup:
$AzApp.Dispose()
$AzStore.Dispose()
$AzStorage.Dispose()