Created
October 27, 2018 10:39
-
-
Save speaktech-account/0ff45190881fb3d3ea4fe0fb514993ea to your computer and use it in GitHub Desktop.
How to export / import Windows share permission settings ref: https://qiita.com/speaktech/items/2785e989557be4635700
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 例1) ディレクトリの移動 | |
PS D:\Tmp> Set-Location -Path D:\Tmp\share | |
PS D:\Tmp\share> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 例2) カレントディレクトリのパスを出力 | |
PS D:\Tmp\share> Get-Location | |
Path | |
---- | |
D:\Tmp\share |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 例3) カレントディレクトリのオブジェクトを変数に代入し、メンバーへアクセス | |
PS D:\Tmp\share> $pwd = Get-Location | |
PS D:\Tmp\share> $pwd.Path | |
D:\Tmp\share |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 例4)共有アクセス権設定を出力 | |
PS D:\Tmp> Get-SmbShare -Special $false | |
Name ScopeName Path Description | |
---- --------- ---- ----------- | |
share * D:\tmp\share | |
Users * C:\Users |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 例5)Dドライブ上の共有アクセス権設定のみ出力 | |
PS D:\Tmp> Get-SmbShare -Special $false | ? { $_.Path -like "D:\*" } | |
Name ScopeName Path Description | |
---- --------- ---- ----------- | |
share * D:\tmp\share |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 例6)Dドライブ上の共有アクセス権設定をXmlファイルへエクスポート | |
PS D:\Tmp> $shareFolder = Get-SmbShare -Special $false | ? { $_.Path -like "D:\*" } | |
PS D:\Tmp> $shareFolder | Export-Clixml -Path D:\Tmp\SmbShare.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 例7)Dドライブ上の共有アクセス権設定をXmlファイルからインポート | |
PS D:\Tmp> Import-Clixml -Path D:\Tmp\SmbShare.xml | |
Name ScopeName Path Description | |
---- --------- ---- ----------- | |
share * D:\tmp\share |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 例8)インポートした共有アクセス権設定を詳細に出力 | |
PS D:\Tmp> Import-Clixml -Path D:\Tmp\SmbShare.xml | Get-SmbShareAccess | |
Name ScopeName AccountName AccessControlType AccessRight | |
---- --------- ----------- ----------------- ----------- | |
share * Everyone Allow Full |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 例9)インポートした共有アクセス権設定を反映 | |
PS D:\Tmp> Import-Clixml -Path D:\Tmp\SmbShare.xml | New-SmbShare | |
Name ScopeName Path Description | |
---- --------- ---- ----------- | |
share * D:\Tmp\share |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 例10)共有アクセス権設定を詳細に出力 | |
PS D:\Tmp> Get-SmbShare -Special $false | Get-SmbShareAccess | |
Name ScopeName AccountName AccessControlType AccessRight | |
---- --------- ----------- ----------------- ----------- | |
Users * BUILTIN\Administrators Allow Full | |
Users * Everyone Allow Full | |
share * Everyone Allow Full |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment