$resourceGroupName = "<resource-group>"
$storageAccountName = "<storage-account>"
# Get reference to storage account
$storageAccount = Get-AzStorageAccount `
-ResourceGroupName $resourceGroupName `
-StorageAccountName $storageAccountName
# If you've never enabled or disabled SMB Multichannel, the value for the SMB Multichannel
# property returned by Azure Files will be null. Null returned values should be interpreted
# as "default settings are in effect". To make this more user-friendly, the following
# PowerShell commands replace null values with the human-readable default values.
$defaultSmbMultichannelEnabled = $false
# Get the current value for SMB Multichannel
Get-AzStorageFileServiceProperty -StorageAccount $storageAccount | `
Select-Object -Property `
ResourceGroupName, `
StorageAccountName, `
@{
Name = "SmbMultichannelEnabled";
Expression = {
if ($null -eq $_.ProtocolSettings.Smb.Multichannel.Enabled) {
$defaultSmbMultichannelEnabled
} else {
$_.ProtocolSettings.Smb.Multichannel.Enabled
}
}
}
若要获取 SMB 多通道的状态,请使用 az storage account file-service-properties show 命令。 在运行这些 Bash 命令前,请记得将 <resource-group> 和 <storage-account> 替换为适合环境的值。
RESOURCE_GROUP_NAME="<resource-group>"
STORAGE_ACCOUNT_NAME="<storage-account>"
# If you've never enabled or disabled SMB Multichannel, the value for the SMB Multichannel
# property returned by Azure Files will be null. Null returned values should be interpreted
# as "default settings are in effect". To make this more user-friendly, the following
# PowerShell commands replace null values with the human-readable default values.
## Search strings
REPLACESMBMULTICHANNEL="\"smbMultichannelEnabled\": null"
# Replacement values for null parameters.
DEFAULTSMBMULTICHANNELENABLED="\"smbMultichannelEnabled\": false"
# Build JMESPath query string
QUERY="{"
QUERY="${QUERY}smbMultichannelEnabled: protocolSettings.smb.multichannel.enabled"
QUERY="${QUERY}}"
# Get protocol settings from the Azure Files FileService object
protocolSettings=$(az storage account file-service-properties show \
--resource-group $RESOURCE_GROUP_NAME \
--account-name $STORAGE_ACCOUNT_NAME \
--query "${QUERY}")
# Replace returned values if null with default values
PROTOCOL_SETTINGS="${protocolSettings/$REPLACESMBMULTICHANNEL/$DEFAULTSMBMULTICHANNELENABLED}"
# Print returned settings
echo $PROTOCOL_SETTINGS
若要启用/禁用 SMB 多通道,请使用 az storage account file-service-properties update 命令。
$resourceGroupName = "<resource-group>"
$storageAccountName = "<storage-account>"
# Get reference to storage account
$storageAccount = Get-AzStorageAccount `
-ResourceGroupName $resourceGroupName `
-StorageAccountName $storageAccountName
# If you've never changed any SMB security settings, the values for the SMB security
# settings returned by Azure Files will be null. Null returned values should be interpreted
# as "default settings are in effect". To make this more user-friendly, the following
# PowerShell commands replace null values with the human-readable default values.
# If you've deliberately set any of your SMB security settings to null, for example by
# disabling SMB channel encryption, comment out the following four lines to avoid
# changing the security settings back to defaults.
$smbProtocolVersions = "SMB2.1", "SMB3.0", "SMB3.1.1"
$smbAuthenticationMethods = "NTLMv2", "Kerberos"
$smbKerberosTicketEncryption = "RC4-HMAC", "AES-256"
$smbChannelEncryption = "AES-128-CCM", "AES-128-GCM", "AES-256-GCM"
# Gets the current values of the SMB security settings
Get-AzStorageFileServiceProperty -StorageAccount $storageAccount | `
Select-Object -Property `
ResourceGroupName, `
StorageAccountName, `
@{
Name = "SmbProtocolVersions";
Expression = {
if ($null -eq $_.ProtocolSettings.Smb.Versions) {
[String]::Join(", ", $smbProtocolVersions)
} else {
[String]::Join(", ", $_.ProtocolSettings.Smb.Versions)
}
}
},
@{
Name = "SmbChannelEncryption";
Expression = {
if ($null -eq $_.ProtocolSettings.Smb.ChannelEncryption) {
[String]::Join(", ", $smbChannelEncryption)
} else {
[String]::Join(", ", $_.ProtocolSettings.Smb.ChannelEncryption)
}
}
},
@{
Name = "SmbAuthenticationMethods";
Expression = {
if ($null -eq $_.ProtocolSettings.Smb.AuthenticationMethods) {
[String]::Join(", ", $smbAuthenticationMethods)
} else {
[String]::Join(", ", $_.ProtocolSettings.Smb.AuthenticationMethods)
}
}
},
@{
Name = "SmbKerberosTicketEncryption";
Expression = {
if ($null -eq $_.ProtocolSettings.Smb.KerberosTicketEncryption) {
[String]::Join(", ", $smbKerberosTicketEncryption)
} else {
[String]::Join(", ", $_.ProtocolSettings.Smb.KerberosTicketEncryption)
}
}
}
RESOURCE_GROUP_NAME="<resource-group>"
STORAGE_ACCOUNT_NAME="<storage-account>"
# If you've never changed any SMB security settings, the values for the SMB security
# settings returned by Azure Files will be null. Null returned values should be interpreted
# as "default settings are in effect". To make this more user-friendly, the commands in the
# following two sections replace null values with the human-readable default values.
# If you've deliberately set any of your SMB security settings to null, for example by
# disabling SMB channel encryption, comment out the following two sections before
# running the script to avoid changing the security settings back to defaults.
# Values to be replaced
REPLACESMBPROTOCOLVERSION="\"smbProtocolVersions\": null"
REPLACESMBCHANNELENCRYPTION="\"smbChannelEncryption\": null"
REPLACESMBAUTHENTICATIONMETHODS="\"smbAuthenticationMethods\": null"
REPLACESMBKERBEROSTICKETENCRYPTION="\"smbKerberosTicketEncryption\": null"
# Replacement values for null parameters. If you copy this into your own
# scripts, you will need to ensure that you keep these variables up-to-date with any new
# options we may add to these parameters in the future.
DEFAULTSMBPROTOCOLVERSIONS="\"smbProtocolVersions\": \"SMB2.1;SMB3.0;SMB3.1.1\""
DEFAULTSMBCHANNELENCRYPTION="\"smbChannelEncryption\": \"AES-128-CCM;AES-128-GCM;AES-256-GCM\""
DEFAULTSMBAUTHENTICATIONMETHODS="\"smbAuthenticationMethods\": \"NTLMv2;Kerberos\""
DEFAULTSMBKERBEROSTICKETENCRYPTION="\"smbKerberosTicketEncryption\": \"RC4-HMAC;AES-256\""
# Build JMESPath query string
QUERY="{"
QUERY="${QUERY}smbProtocolVersions: protocolSettings.smb.versions,"
QUERY="${QUERY}smbChannelEncryption: protocolSettings.smb.channelEncryption,"
QUERY="${QUERY}smbAuthenticationMethods: protocolSettings.smb.authenticationMethods,"
QUERY="${QUERY}smbKerberosTicketEncryption: protocolSettings.smb.kerberosTicketEncryption"
QUERY="${QUERY}}"
# Get protocol settings from the Azure Files FileService object
PROTOCOLSETTINGS=$(az storage account file-service-properties show \
--resource-group $RESOURCE_GROUP_NAME \
--account-name $STORAGE_ACCOUNT_NAME \
--query "${QUERY}")
# Replace returned values if null with default values
PROTOCOLSETTINGS="${protocolSettings/$REPLACESMBPROTOCOLVERSION/$DEFAULTSMBPROTOCOLVERSIONS}"
PROTOCOLSETTINGS="${protocolSettings/$REPLACESMBCHANNELENCRYPTION/$DEFAULTSMBCHANNELENCRYPTION}"
PROTOCOLSETTINGS="${protocolSettings/$REPLACESMBAUTHENTICATIONMETHODS/$DEFAULTSMBAUTHENTICATIONMETHODS}"
PROTOCOLSETTINGS="${protocolSettings/$REPLACESMBKERBEROSTICKETENCRYPTION/$DEFAULTSMBKERBEROSTICKETENCRYPTION}"
# Print returned settings
echo $PROTOCOLSETTINGS