LoginSignup
0
2

More than 1 year has passed since last update.

[02] PowerShell実践例 ... Samba 認証の自動化

Last updated at Posted at 2021-07-01
本シリーズのトップページ
https://qiita.com/robozushi10/items/0b0605257ad39bc22895
その他 - 関連記事
[備忘録] Samba サーバおよびクライアントの実践例

はじめに

CI/CD の中で Samba 認証の自動化が必要になったので、書き残しておく.

 

環境

Windows 10 Pro
PowerShell バージョン 6系

 

接続条件

項目
サーバ名 myserver
ユーザ名 myname
パスワード mypassword
所属ドメイン mydomain

コード

try
{
  $local:SVR = '\\myserver'
  $RET = (New-SMBMapping -RemotePath $local:SVR -Username 'mydomain\myname' -Password mypassword)
  if($($RET.Status) -ne 'OK')
  {
    throw "$local:SVR へのアクセスに失敗しました"
  }
}
catch
{
  Write-Host "$($_.Exception.Message)"
}
0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2