Skip to main content
  • Place orders quickly and easily
  • View orders and track your shipping status
  • Enjoy members-only rewards and discounts
  • Create and access a list of your products
  • Manage your Dell EMC sites, products, and product-level contacts using Company Administration.

Dell Command PowerShell Providerセキュア パスワード機能

Summary: Dell Command |PowerShell Provider Secure Password機能、ConvertTo-SecureString、ConvertFrom-SecureString

This article may have been automatically translated. If you have any feedback regarding its quality, please let us know using the form at the bottom of this page.

Article Content


Symptoms

対象製品:

  • Dell Command | PowerShell Provider

Cause

-

Resolution

安全なパスワードの背後にある概念は、本番スクリプトでは、重要なパスワードをプレーン ビューとして渡してはならないということです。これは深刻なセキュリティの欠如です。PowerShellを使用すると、パスワードを保護するか、少なくともパスワードの可視性を減らすことができます。まず、セキュア文字列の一般的な側面について説明してから、Dell Command PowerShell Provider(DCPP)がPowerShellの本質的な機能を活用してパスワードを保護する方法について説明します。

コンソールでユーザー名とパスワードをユーザーから読み取りたいとします。ユーザー名は一般的にセキュリティを必要とせず、すべてのユーザーに表示できることを認識しています。しかし、パスワードについては、ユーザーのパスワードを知らせるべきではありません。次のコマンドを使用して、この要件を容易にすることができます。

$user = Read-Host "Enter Username"

$pass = Read-Host "Enter Password" -AsSecureString

上記は、パスワードなどの重要な情報を保護する必要がある場合に、セキュリティを強化する方法の概要です。上記の例では、$pass変数は タイプ System.Security.SecureStringです。DcPPの側面に触れる前に、PowerShellが提供する他の2つの広く使用されているコマンドレットを紹介します。

2つのコマンドは と ConvertTo-SecureStringConvertFrom-SecureStringです。ConvertTo-SecureString プレーン テキストをタイプ System.Security.SecureStringに変換します。以下に例を示します。

"P@ssword1" | ConvertTo-SecureString -AsPlainText -Force

上の例では、プレーン テキスト P@assword1 がタイプ System.Security.SecureStringに変換されています。これは多くの情報であり、広く使用されている場合と使用されていない場合があります。

次のコマンドレット ConvertFrom-SecureString は、セキュアな文字列を暗号化された標準文字列に変換するために使用される、より広く使用されているコマンドレットです。の ConvertTo-SecureString 主な制限事項は、出力を将来使用するためにファイルに直接書き込むことができないことです。この制限を ConvertFrom-SecureString 克服するために、ファイルに簡単に保存できる暗号化された標準文字列に変換 System.Security.SecureString する必要があります。

プレーン テキスト P@ssword1 を安全な文字列に変換し、出力をパイプ処理して ConvertFrom-SecureString 暗号化された文字列を取得します。これにより、安全かつ便利にファイルに保存できます。

例として、管理者パスワードが設定されていて、これをファイルに保存する必要がある場合は、コンピューターでとします。これを行うには、次の手順を実行します。

Read-Host "Enter Admin Password" -AsSecureString |
ConvertFrom-SecureString | Out-File "C:\Scripts\AdminPassword.txt"

次のように、この管理者パスワードを安全なオブジェクトとして変数に戻すことができます。

$pass = Get-Content "C:\Scripts\AdminPassword.txt" | ConvertTo-SecureString

次に、DCPPの安全なパスワードを活用する方法を検討します。DCPPでは、ユーザーのコンピューターにシステムパスワードまたは管理者パスワードが設定されている場合、すべての set コマンドに対してそれぞれのパスワードを渡す必要があります。このパスワードを平文として入力すると、セキュリティが侵害されます。そのため、パスワードを「 .」と System.Security.SecureString入力する必要があります。また、パスワードをSecureString渡すときは、通常–Passwordのスイッチではなく、スイッチでパスワードを-PasswordSecure渡す必要があります。次の例は、ユーザーがパスワードをに設定AdvancedBatteryChargeCfgして渡SecureStringそうとしている場合ですDisabled

Set-item AdvancedBatteryChargeCfg disabled –PasswordSecure $pass

ここでは、$passはシステムパスワードと管理者パスワードを保持しており、タイプ System.Security.SecureStringは です。上記のディスカッションと同様に、次のように読 $pass むことができます。

$pass = Read-Host "Enter system/admin password" –AsSecureString

必要に応じて、次のようにファイルに保存 $pass できます。

$pass| ConvertFrom-SecureString | Out-File "C:\Scripts\AdminPassword.txt

Additional Information

Article Properties


Affected Product

Dell Command | Powershell Provider

Last Published Date

11 Sep 2023

Version

7

Article Type

Solution