只是保哥的例子,不是完整的範例,借這篇把內容補齊而己
系統管理員身分執行 PowerShell 命令提示字元視窗。
執行︰
Install-Module -Name AzureAD
Get-MsolAccountSku
AccountSkuId ActiveUnits WarningUnits ConsumedUnits
------------ ----------- ------------ -------------
sample:POWER_BI_PRO 100 0 0
sample:AAD_BASIC 100 0 0
sample:ENTERPRISEPACK 100 0 0
sample:SPE_E3 100 0 0
$licensePlanList=(Get-AzureADSubscribedSku)
$AADName = 'sample'
#### 原本保哥的例子裡 並不會列出所有USER,要加上 -All $true 才會列出全部
$users = (Get-AzureADUser -All $true) | Where-Object { $_.UserType -ne 'Guest' } | Select-Object UserPrincipalName
foreach ($user in $users)
{
$userUPN = $user.UserPrincipalName
Write-Host "############################# $userUPN #############################"
$is_old_license=$false
$is_new_license=$false
$userList = Get-AzureADUser -ObjectID $userUPN | Select -ExpandProperty AssignedLicenses | Select SkuID
$userList | ForEach {
$sku=$_.SkuId
$licensePlanList | ForEach {
If ( $sku -eq $_.ObjectId.substring($_.ObjectId.length - 36, 36) ) {
If ( $_.SkuPartNumber -eq 'ENTERPRISEPACK' ) { $is_old_license = $true; Write-Host "Old License:" $_.SkuPartNumber }
If ( $_.SkuPartNumber -eq 'SPE_E3' ) { $is_new_license = $true; Write-Host "New License:" $_.SkuPartNumber }
}
}
}
if ( $is_old_license -and $is_new_license ) {
# 兩個授權都有,只要刪除舊的授權
Write-Host "The 'ENTERPRISEPACK' license should be removed."
Set-MsolUserLicense -UserPrincipalName $userUPN -RemoveLicenses "$($AADName):ENTERPRISEPACK"
}
elseif ( $is_old_license -and (-not $is_new_license)) {
# 只有舊的授權,就置換成新的授權
Write-Host "The 'ENTERPRISEPACK' license should be replaced with 'SPE_E3' license $is_old_license"
Set-MsolUserLicense -UserPrincipalName $userUPN -AddLicenses "$($AADName):SPE_E3" -RemoveLicenses "$($AADName):ENTERPRISEPACK"
}
elseif ( (-not $is_old_license) -and ($is_new_license)) {
# 只有新的授權,就代表設定正確!
Write-Host "The new License 'SPE_E3' is applied correctly."
}
elseif ( (-not $is_old_license) -and (-not $is_new_license)) {
# 兩個授權都沒有,基本上就不特別設定
Write-Host "No License is available on this user."
}
}
P.S. 原本 "
保哥的例子裡是單引號,但是我執行起來會發生 Unable to assign this license because it is invalid. Use the Get-MsolAccountSku cmdlet to retrieve a list of valid licenses. 改成雙引號就好了。
powershell
Microsoft 365
先到IP的組態裡幫IP設個DNS名稱 DNS 名稱標籤 (選用): 選一個可以代表這個IP功用的名字。Azure 會自動加上尾碼。 設定 ReverseFqdn。由於 UI 上並沒有提供設定的功能,所以要使用Azure Powershell來設定。 $pip = Get-AzPublicIpAddress -Name "Public的名字" -ResourceGroupName "ResourceGroup的名字" $pip.DnsSettings.ReverseFqdn = "www.domain.com." #這裡注意fqdn最後要有個. Set-AzPublicIpAddress -PublicIpAddress $pip
Sep 13, 2021啟用VM的巢狀虛擬化 注意: Guest OS 的版本要在 Windows Server build 18945 版本以上,這裡的範例是使用 Windows Server 2004的版本 在VM安裝完成後,第一步就是先啟用VM的巢狀虛擬化 以Hyper-V為例(使用powershell) Get-VM "VM的名字" | Set-VMProcessor -ExposeVirtualizationExtensions $true 各種VM啟用的方式,參考資料如下
Jul 20, 2021今天想要修改Server Core VM的IP,但是使用sconfig卻看不到我想要修改的網卡。 Microsoft (R) Windows Script Host Version 5.812 Copyright (C) Microsoft Corp. 1996-2006, 著作權所有,並保留一切權利 正在檢查系統... =============================================================================== 伺服器設定 ===============================================================================
May 25, 2021情境 當使用指令 docker service logs [service name] 要讀取log時,如果發生下列錯誤。 error from daemon in stream: Error grabbing logs: rpc error: code = Unknown desc = warning: incomplete log stream. some logs could not be retrieved for the following reasons: node XXXXXXXXXXXXXXXXXXXXXXXXXXXXX is not available 這似乎是docker 的bug ,在2017年就有人在docker的官方github發這個issue,但是到今天(2021年3月,版本19.03.14)為止都還沒解決。 看起來,把host重新開機或者把Service 移除再重新部署都沒有辦法。 解決方法
Feb 26, 2021or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up