PowerShellのファイル出力先を実行ユーザのデスクトップにする


PowerShellのファイル出力先を、実行したユーザのデスクトップにする場合に、「$env:USERPROFILE + “\Desktop\filename.txt”」と指定するのは間違い。

これだと、ローカルディスクでは無く、ファイルサーバ上にDesktopが置かれるような環境に対応できない。

「[Environment]::GetFolderPath(“Desktop”)」で取得するのが正しい。

実際に、どういう風になるのか見てみる・・・

PS C:\Users\osakanataro> $env:USERPROFILE + "\Desktop"
C:\Users\osakanataro\Desktop

PS C:\Users\osakanataro> [Environment]::GetFolderPath("Desktop")
\\fileserver1\Redirects$\osakanataro\Desktop

Desktop以外に指定できる内容については「Environment.SpecialFolder Enum」(以前のURL Environment.SpecialFolder Enumeration)参照のこと。

「Added in the .NET Framework 4.」なっているものは、Windows7/WindowsServer2008などの古めのWindowsでは動かないので注意。

PowerShellを使って日本語メールを送信する方法(v2.0も対応する版)


PowerShellを使ってメールを送信する方法を探すと2種類でてくる

・PowerShell cmdletの「Send-MailMessage」を使う
・Net.Mail.SmtpClient と Net.Mail.MailMessage を使う

UTF8で日本語メールを送る場合を考えると、Send-MailMessageを使用することで用が足りるようである。

ただ、Windows7で標準インストールとなるPowerShell v2.0だと、「Send-MailMessage -Encoding UTF8 ~」と指定すると、下記のエラーとなり、エンコーディングの指定がうまく行かない。そして、エンコーディングを指定せずに送ると日本語は文字化ける。

Send-MailMessage : パラメーター 'Encoding' をバインドできません。"eutf8" の値を "System.String" 型から "System.Text.Encoding" 型に変換できません。
発生場所 行:1 文字:28
+ Send-MailMessage -Encoding eutf8
+                            ~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Send-MailMessage]、ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.SendMailMessage

これは、「UTF8」の代わりに、System.Text.Encodingに変換したUTF8を指定「([System.Text.Encoding]::UTF8)」することで解決できる。

また、PowerShell v2.0のSend-MailMessageには、SMTPポートの番号指定が無い。
25番以外の場合は、「Net.Mail.SmtpClient と Net.Mail.MailMessage」の方を行う必要があるようだ。

そんなわけで、スクリプト例は下記の様になる。
なお、PowerShell Core 6.0でも利用できた。

$smtpserver= "サーバ名"
$port= 25
$mailfrom="ユーザ名@ドメイン名"
$mailtoArray=@(
   "ユーザ1@ドメイン名",
   "ユーザ2@ドメイン名",
   "ユーザ3@ドメイン名"
   )
$mailsubject="メール送信テスト"
$mailbody="これはメールの送信テストです。`n"+"正常に送信出来ていますか?"

if($PSVersionTable.PSVersion.Major -gt 2){
   Send-MailMessage -From $mailfrom -To $mailtoArray -SmtpServer $smtpserver -Port $port -Encoding utf8 -Subject $mailsubject -Body $mailbody
}else{
   # PowerShell v2.0用処理。ポート番号指定除去と、Encoding指定方法変更
   Send-MailMessage -From $mailfrom -To $mailtoArray -SmtpServer $smtpserver -Encoding ([System.Text.Encoding]::UTF8) -Subject $mailsubject -Body $mailbody
}

え?

ISO-2022-JPでメール送らなくていいのかって?

いまどきUTF-8を受け取れない環境は論外なので気にしなくていいです。(iPhone/Androidの絵文字は基本Unicodeベースなので、送信されるメールはISO-2022-JPではありません)

PowerCLIで対象の仮想マシンを選択してvMotionを実行



VMware vSphere環境で、PowerCLIを使って、仮想マシンのvMotionを行うスクリプトを作成した。

ブラウザを起動し、vSphere Web Clientにログインして、vMotionを実行するまでにかかる時間と
PowerShellを起動して、コマンドを実行する時間を比べると
コマンドを実行したほうがずっと早い、ということで作成した。

というか、vSphere Web Clientは重すぎ!

# 普通のPowerShell/PowerShell ISEからvSphere PowerCLIのコマンドを使うために必要な設定
Add-PSSnapin VMware.VimAutomation.Core
# vCenterサーバに接続
$VC=Connect-VIServer -User "administrator@vsphere.local" -Password "パスワード" "vCenterサーバ"  -WarningAction 0
# 仮想マシンの選択
$VM=Get-VM | Out-GridView -Title "Please select VM" -PassThru

# 選択した仮想マシンが所属しているクラスタのESXiホストリストから選択
$ESX=Get-VMHost -Location  ($VM.ResourcePool).Name | Out-GridView -Title "Please select ESXi host" -PassThru

# 選択したものを表示
Write-Host "VirtualMachine:" $VM.Name
Write-Host "Move from:" $VM.VMHost " to:" $ESX.Name

# vMotionを実行
Move-VM -VM $VM -Destination $ESX

なお、「$VM=Get-VM | Out-GridView -Title “Please select VM” -PassThru」を
「$VM=Get-VM | Select Name,VMHost | Out-GridView -Title “Please select VM” -PassThru」
という風に替えると、選択ウィンドウに表示する内容を変えることができる。

<注意>
WindowsにインストールされているPowerShellのバージョンが低いと「Out-GridView -PassThru」が利用できないため、動作しません。
たしか、PowerShell ver3以降が必要だったような・・・

Azure上の仮想マシンのディスク拡張手法 2016年1月版



Azure上の仮想マシンのディスクがいっぱいになったので拡張する必要があった。

2015年6月にやったときは、「Azure上の仮想ディスクを拡張する」の手順でやろうとしたら、Windows7のPowerShellからではうまくいかずに、WindowsServer2012R2の仮想マシンを別途立て、そこから実行して拡張した。

で・・・今回、Windows7から実行できるようになっていないかを確認しつつ手順を確認していった。

参考資料
・「How to install and configure Azure PowerShell
・「Azure 仮想マシン (IaaS VM) のディスクの拡張について

2016年1月18日時点でのポイント

・最新版のAzure PowerShellは、Githubの「https://github.com/Azure/azure-powershell」で公開されている

・最新版はversion 1.1.0。ただし、PoewrShell 1.0,2.0環境では動かない。

・インストールは「Microsoft Web Platform Installer」による統合的なインストールか、「http://aka.ms/webpi-azps」(今日時点だとWindowsAzurePowershellGet.3f.3f.3fnew.exeがダウンロードされる)による単独インストールにて行う
(古いバージョンは勝手にアンインストールしてくれる)

・ディスク拡張時は、Aazure仮想マシンは停止している必要がある

・「Update-AzureDisk」は、ラベル名も指定しないとエラーになる。
 しかも、ラベル名設定していない場合に「-Label “”」とやってもエラーになる。
 「-Label ” “」とスペースでもいいので指定しなければならない

・現状の仮想ディスクのラベル名情報を確認するには「Get-AzureDisk」で行う

・以前はサブスクリプションの選択とかストレージアカウントの選択など、面倒な処理が必要だったが
 省略できるようになっている。

実際にやった手順の概要

1. Microsoft Azure PowerShellを起動
2. 「Add-AzureAccount」で認証
3. 「Get-AzureVM」でAzure仮想マシン一覧を取得

PS C:\> Get-AzureVM

ServiceName                             Name                                    Status
-----------                             ----                                    ------
service-test                            webserver1                              ReadyRole
service-test                            sqlserver1                              ReadyRole
service-test2                           webserver1                              StoppedVM
service-test2                           sqlserver1                              StoppedVM

PS C:\>

4. 対象仮想マシンの仮想マシン情報を取得
「(Get-AzureVM -ServerName サービス名 -Name 仮想マシン名).VM」を実行する。

PS C:\> (Get-AzureVM -ServiceName servite-test2 -Name sqlserver1).VM

AvailabilitySetName               :
ConfigurationSets                 : {Microsoft.WindowsAzure.Commands.ServiceManagement.Model.NetworkConfigurationSet}
DataVirtualHardDisks              : {servite-test2-sqlserver1-0-201412020519500167, servite-test2-sqlserver1-1-201412020521210099}
Label                             :
OSVirtualHardDisk                 : Microsoft.WindowsAzure.Commands.ServiceManagement.Model.OSVirtualHardDisk
RoleName                          : servite-test2
RoleSize                          : Standard_D2
RoleType                          : PersistentVMRole
WinRMCertificate                  :
X509Certificates                  :
NoExportPrivateKey                : False
NoRDPEndpoint                     : False
NoSSHEndpoint                     : False
DefaultWinRmCertificateThumbprint :
ProvisionGuestAgent               : True
ResourceExtensionReferences       : {BGInfo, IaaSAntimalware}
DataVirtualHardDisksToBeDeleted   :
VMImageInput                      :
PS C:\>

上記出力中の「DataVirtualHardDisks」がディスクの名前。
このAzure仮想マシンには2つのディスクが接続されている。

5. 「Get-AzureDisk -DiskName “ディスクの名前”」でディスク情報の詳細を取得

PS C:\> Get-AzureDisk -DiskName "servite-test2-sqlserver1-0-201412020519500167"

AffinityGroup        :
AttachedTo           : RoleName: sqlserver1
                       DeploymentName: sqlserver1
                       HostedServiceName: service-test2
IsCorrupted          : False
Label                :
Location             : Japan West
DiskSizeInGB         : 200
MediaLink            : https://xxxxxxxxxx.blob.core.windows.net/vhds/sqlserver1-E-drive.vhd
DiskName             : servite-test2-sqlserver1-0-201412020519500167
SourceImageName      :
OS                   :
IOType               : Standard
OperationDescription : Get-AzureDisk
OperationId          : 2905xxxx-xxxx-xxxx-xxxx-1252bc53xxxx
OperationStatus      : Succeeded

PS C:\>

6. 「Update-AzureDisk -DiskName “ディスク名” -ResizedSizeInGB 数値 -Label “ラベル名”」でディスクの容量指定

PS C:\> Update-AzureDisk -DiskName "servite-test2-sqlserver1-0-201412020519500167" -ResizedSizeInGB 250 -Label " "

OperationDescription                    OperationId                             OperationStatus
--------------------                    -----------                             ---------------
Update-AzureDisk                        9154xxxx-xxxx-xxxx-xxxx-f79f842fxxxx    Succeeded
PS C:\>

Get-AzureDiskで確認したときに「Label:」になにもないからといって、-Labelを指定しないと・・・

PS C:\> Update-AzureDisk -DiskName "servite-test2-sqlserver1-0-201412020519500167" -ResizedSizeInGB 250
Update-AzureDisk : 値を Null にすることはできません。
パラメーター名:parameters.Label発生場所 行:1 文字:1
+ Update-AzureDisk -DiskName "servite-test2-sqlserver1-0-201412020519500167" -R ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Update-AzureDisk]、ArgumentNullException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.UpdateAzureDiskCommand

PS C:\>

なにも設定されていないから「-Label “”」としても・・・

PS C:\> Update-AzureDisk -DiskName "servite-test2-sqlserver1-0-201412020519500167" -ResizedSizeInGB 250 -label ""
Update-AzureDisk : パラメーター 'Label の引数を確認できません。引数が null または空です。null または空でない引数を指定して、コマンドを再度実行してください。発生場所 行:1 文字:106
+ ... InGB 250 -label ""
+                    ~~
    + CategoryInfo          : InvalidData: (:) [Update-AzureDisk]、ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.
   UpdateAzureDiskCommand

PS C:\>

と、めんどくさいです。
「-Label ” “」とスペースでもいいので、何か文字列を指定すると、コマンドが実行できます。

7. 仮想マシンの電源ON
8. OS内でファイルシステムの拡張を実行

以上で拡張が完了です。

vSphere PowerCLIの一部コマンドがPowerShell ISEで動作しない



2016/12/15追記

Add-Snappinは、古いPowerShellの場合だけだったようなので、新しいバージョンの場合にも対応したものを下記に記載しています。

vSphere PowerCLIの一部コマンドがPowerShell ISEで動作しない 2016/12/15版


vSphere PowerCLIで変な動作に遭遇した。
vSphere PowerCLIの一部コマンドがPowerShell ISE上だと動作しない、という問題である。
元々、PowerShell ISEの標準設定ではvSphere PowerCLIのコマンドは動かない。
「Add-PSSnapin VMware.VimAutomation.Core」を追加し、モジュールを読み込ませる必要があるのだが、それを行っても動かないものがいくつかあることが分かった。

まずは状況の確認から・・・

現在のvSphere Power CLIのバージョンを確認
Determining the build number for vSphere PowerCLI or VI Toolkit for Windows」より「Get-VIToolkitVersion」を実行。

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Get-VIToolkitVersion

PowerCLI Version
----------------
   VMware vSphere PowerCLI 6.0 Release 1 build 2548067
---------------
Component Versions
---------------
   VMWare AutoDeploy PowerCLI Component 6.0 build 2358282
   VMWare ImageBuilder PowerCLI Component 6.0 build 2358282
   VMware License PowerCLI Component 6.0 build 2315846
   VMware vSphere PowerCLI Component 6.0 build 2548068
   VMware Cloud Infrastructure Suite PowerCLI Component 6.0 build 2548068
   VMware HA PowerCLI Component 6.0 build 2510422
   VMware PowerCLI Component for Storage Management 6.0 build 2522368
   VMware VDS PowerCLI Component 6.0 build 2548068



PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI>

(ちなみに、この記事を書いてる時点では、これより新しいバージョンが出ている)

vCenterサーバに接続

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Connect-VIServer -Server vCenterServer -User root -Password vmware

Name                           Port  User
----                           ----  ----
vCenterServer                  443   root


PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI>

そして、「Get-VdsCommand」を実行してvSphre PowerCLIが提供するvDS関連コマンド一覧を取得。

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Get-VdsCommand

CommandType     Name                                               ModuleName
-----------     ----                                               ----------
Cmdlet          Add-VDSwitchPhysicalNetworkAdapter                 VMware.Vi...
Cmdlet          Add-VDSwitchVMHost                                 VMware.Vi...
Cmdlet          Export-VDPortGroup                                 VMware.Vi...
Cmdlet          Export-VDSwitch                                    VMware.Vi...
Cmdlet          Get-VDBlockedPolicy                                VMware.Vi...
Cmdlet          Get-VDPort                                         VMware.Vi...
Cmdlet          Get-VDPortgroup                                    VMware.Vi...
Cmdlet          Get-VDPortgroupOverridePolicy                      VMware.Vi...
Cmdlet          Get-VDSecurityPolicy                               VMware.Vi...
Cmdlet          Get-VDSwitch                                       VMware.Vi...
Cmdlet          Get-VDSwitchPrivateVlan                            VMware.Vi...
Cmdlet          Get-VDTrafficShapingPolicy                         VMware.Vi...
Cmdlet          Get-VDUplinkLacpPolicy                             VMware.Vi...
Cmdlet          Get-VDUplinkTeamingPolicy                          VMware.Vi...
Cmdlet          New-VDPortgroup                                    VMware.Vi...
Cmdlet          New-VDSwitch                                       VMware.Vi...
Cmdlet          New-VDSwitchPrivateVlan                            VMware.Vi...
Cmdlet          Remove-VDPortGroup                                 VMware.Vi...
Cmdlet          Remove-VDSwitch                                    VMware.Vi...
Cmdlet          Remove-VDSwitchPhysicalNetworkAdapter              VMware.Vi...
Cmdlet          Remove-VDSwitchPrivateVlan                         VMware.Vi...
Cmdlet          Remove-VDSwitchVMHost                              VMware.Vi...
Cmdlet          Set-VDBlockedPolicy                                VMware.Vi...
Cmdlet          Set-VDPort                                         VMware.Vi...
Cmdlet          Set-VDPortgroup                                    VMware.Vi...
Cmdlet          Set-VDPortgroupOverridePolicy                      VMware.Vi...
Cmdlet          Set-VDSecurityPolicy                               VMware.Vi...
Cmdlet          Set-VDSwitch                                       VMware.Vi...
Cmdlet          Set-VDTrafficShapingPolicy                         VMware.Vi...
Cmdlet          Set-VDUplinkLacpPolicy                             VMware.Vi...
Cmdlet          Set-VDUplinkTeamingPolicy                          VMware.Vi...
Cmdlet          Set-VDVlanConfiguration                            VMware.Vi...


PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> 

ここまでは良い。

PowerShell ISEでの動作が問題。
PowerShell ISE上部の編集画面に下記を入力。

Add-PSSnapin VMware.VimAutomation.Core
Get-VIToolkitVersion
Connect-VIServer -Server vCenterServer -User root -Password vmware
Get-VdsCommand

最初の1行はvSphere PowerCLIのコマンドを実行させるため設定。
これを実行すると・・・

PS C:\Users\osakanataro> Add-PSSnapin VMware.VimAutomation.Core
Get-VIToolkitVersion
Connect-VIServer -Server vCenterServer -User root -Password vmware
Get-VdsCommand

Get-VIToolkitVersion : 用語 'Get-VIToolkitVersion' は、コマンドレット、関数、スクリプト ファイル、または操作可能なプログラムの名前として認識されません。名前が正しく記述されていることを確認し、パスが含まれている場合はそのパスが正しいことを確認してから、
再試行してください。
発生場所 行:2 文字:1
+ Get-VIToolkitVersion
+ ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-VIToolkitVersion:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
 

Name                           Port  User                          
----                           ----  ----                          
vCenterServer                  443   root                          
Get-VdsCommand : 用語 'Get-VdsCommand' は、コマンドレット、関数、スクリプト ファイル、または操作可能なプログラムの名前として認識されません。名前が正しく記述されていることを確認し、パスが含まれている場合はそのパスが正しいことを確認してから、再試行してください。
発生場所 行:4 文字:1
+ Get-VdsCommand
+ ~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-VdsCommand:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
 



PS C:\Users\osakanataro> 

エラーになる・・・
なぜなのか・・・

まずはPowerShell ISE内で「Get-Module」を実行し、現在使用できるコマンドを確認

PS C:\Users\osakanataro> Get-Module

ModuleType Version    Name                                ExportedCommands                                                                            
---------- -------    ----                                ----------------                                                                            
Script     1.0.0.0    ISE                                 {Get-IseSnippet, Import-IseSnippet, New-IseSnippet}                                         
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}                          
Manifest   3.0.0.0    Microsoft.PowerShell.Security       {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-AuthenticodeSignature...}   
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}                                   
Manifest   3.0.0.0    Microsoft.WSMan.Management          {Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan, Enable-WSManCredSSP...}             



PS C:\Users\osakanataro> 

比較のためvSphere PowerCLIの方でも「Get-Module」を実行してみる

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Get-Module

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     0.0        Initialize-VMware_VimAutomation_Cis
Script     0.0        Initialize-VMware_VimAutomation_Vds
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add...
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-T...
Binary     6.0.0.0    VMware.VimAutomation.Cis.Core       {Connect-CisServer...
Manifest   6.0.0.0    VMware.VimAutomation.Core           {Add-PassthroughDe...
Binary     6.0.0.0    VMware.VimAutomation.HA             Get-DrmInfo
Manifest   6.0.0.0    VMware.VimAutomation.Sdk
Binary     6.0.0.0    VMware.VimAutomation.Storage        {Export-SpbmStorag...
Binary     6.0.0.0    VMware.VimAutomation.Vds            {Add-VDSwitchPhysi...


PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI>

全然違う
「VMware.VimAutomation.Vds」を追加すると実行できそうな雰囲気・・・

しかし、「Add-PSSnapin VMware.VimAutomation.Vds」は下記のエラーとなる。

Add-PSSnapin : Windows PowerShell スナップイン 'VMware.VimAutomation.Vds' がこのコンピューターにインストールされていません。
発生場所 行:2 文字:1
+ Add-PSSnapin VMware.VimAutomation.Vds
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (VMware.VimAutomation.Vds:String) [Add-PSSnapin]、PSArgumentException
    + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand

ではどうするか?

「Get-Command -Module モジュール名」で指定したモジュールでどんなコマンドが実行できるかを表示すると実行でいるようになるらしい。

そんな馬鹿な、と思いつつ、$DUMMY環境変数に放り込むように変更。

Add-PSSnapin VMware.VimAutomation.Core
$DUMMY=Get-Command -Module VMware.VimAutomation.Vds
Get-VIToolkitVersion
Connect-VIServer -Server vCenterServer -User root -Password vmware
Get-VdsCommand

そして実行

PS C:\Users\osakanataro> Add-PSSnapin VMware.VimAutomation.Core
$DUMMY=Get-Command -Module VMware.VimAutomation.Vds
Get-VIToolkitVersion
Connect-VIServer -Server vCenterServer -User root -Password vmware
Get-VdsCommand


PowerCLI Version
----------------
   VMware vSphere PowerCLI 6.0 Release 1 build 2548067
---------------
Component Versions
---------------
   VMWare AutoDeploy PowerCLI Component 6.0 build 2358282
   VMWare ImageBuilder PowerCLI Component 6.0 build 2358282
   VMware License PowerCLI Component 6.0 build 2315846
   VMware vSphere PowerCLI Component 6.0 build 2548068
   VMware VDS PowerCLI Component 6.0 build 2548068


IsConnected   : True
Id            : /VIServer=root@vCenterServer:443/
ServiceUri    : https://vCenterServer/sdk
SessionSecret : cb8924f9fb4b2cb6cb75a357d8127e2154376d17
Name          : vCenterServer
Port          : 443
SessionId     : cb8924f9fb4b2cb6cb75a357d8127e2154376d17
User          : root
Uid           : /VIServer=root@vCenterServer:443/
Version       : 6.0
Build         : 2776510
ProductLine   : vpx
InstanceUuid  : 1a31cfc8-0931-4752-9573-461f044cc2d4
RefCount      : 6
ExtensionData : VMware.Vim.ServiceInstance
Client        : VMware.VimAutomation.ViCore.Impl.V1.VimClient


Verb                : Add
Noun                : VDSwitchPhysicalNetworkAdapter
HelpFile            : VMware.VimAutomation.Vds.Commands.dll-Help.xml
PSSnapIn            : 
ImplementingType    : VMware.VimAutomation.Vds.Commands.Cmdlets.AddVDSwitchPhysicalNetworkAdapter
Definition          : 
                      Add-VDSwitchPhysicalNetworkAdapter [-VMHostPhysicalNic] <PhysicalNic&#91;&#93;> [-DistributedSwitch] <DistributedSwitch> [-VirtualNicPor
                      tgroup <VDPortgroup&#91;&#93;>] [-VMHostVirtualNic <HostVirtualNic&#91;&#93;>] [-Server <VIServer&#91;&#93;>] [-WhatIf] [-Confirm] [<CommonParameters>]
                      
DefaultParameterSet : 
OutputType          : {System.Void}
Options             : ReadOnly
Name                : Add-VDSwitchPhysicalNetworkAdapter
CommandType         : Cmdlet
Visibility          : Public
ModuleName          : VMware.VimAutomation.Vds
Module              : VMware.VimAutomation.Vds
RemotingCapability  : PowerShell
Parameters          : {[VMHostPhysicalNic, System.Management.Automation.ParameterMetadata], [DistributedSwitch, System.Management.Automation.Parameter
                      Metadata], [VirtualNicPortgroup, System.Management.Automation.ParameterMetadata], [VMHostVirtualNic, System.Management.Automatio
                      n.ParameterMetadata]...}
ParameterSets       : {[-VMHostPhysicalNic] <PhysicalNic&#91;&#93;> [-DistributedSwitch] <DistributedSwitch> [-VirtualNicPortgroup <VDPortgroup&#91;&#93;>] [-VMHostVi
                      rtualNic <HostVirtualNic&#91;&#93;>] [-Server <VIServer&#91;&#93;>] [-WhatIf] [-Confirm] [<CommonParameters>]}
HelpUri             : http://www.vmware.com/support/developer/PowerCLI/PowerCLI60R1/html/Add-VDSwitchPhysicalNetworkAdapter.html
DLL                 : C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Modules\VMware.VimAutomation.Vds\VMware.VimAutomation.Vds.Commands
                      .dll

<略>

Verb                : Set
Noun                : VDVlanConfiguration
HelpFile            : VMware.VimAutomation.Vds.Commands.dll-Help.xml
PSSnapIn            : 
ImplementingType    : VMware.VimAutomation.Vds.Commands.Cmdlets.Policies.SetVDVlanConfiguration
Definition          : 
                      Set-VDVlanConfiguration -VDPortgroup <VDPortgroup&#91;&#93;> [-DisableVlan] [-VlanId <int>] [-VlanTrunkRange <VlanRangeList>] [-PrivateV
                      lanId <int>] [-WhatIf] [-Confirm] [<CommonParameters>]
                      
                      Set-VDVlanConfiguration -VDSwitch <VDSwitch&#91;&#93;> [-DisableVlan] [-VlanId <int>] [-VlanTrunkRange <VlanRangeList>] [-PrivateVlanId 
                      <int>] [-WhatIf] [-Confirm] [<CommonParameters>]
                      
                      Set-VDVlanConfiguration -VDPort <VDPort&#91;&#93;> [-DisableVlan] [-VlanId <int>] [-VlanTrunkRange <VlanRangeList>] [-PrivateVlanId <int
                      >] [-WhatIf] [-Confirm] [<CommonParameters>]
                      
DefaultParameterSet : 
OutputType          : {VMware.VimAutomation.Vds.Types.V1.VlanConfiguration}
Options             : ReadOnly
Name                : Set-VDVlanConfiguration
CommandType         : Cmdlet
Visibility          : Public
ModuleName          : VMware.VimAutomation.Vds
Module              : VMware.VimAutomation.Vds
RemotingCapability  : PowerShell
Parameters          : {[VDPortgroup, System.Management.Automation.ParameterMetadata], [VDSwitch, System.Management.Automation.ParameterMetadata], [VDP
                      ort, System.Management.Automation.ParameterMetadata], [DisableVlan, System.Management.Automation.ParameterMetadata]...}
ParameterSets       : {-VDPortgroup <VDPortgroup&#91;&#93;> [-DisableVlan] [-VlanId <int>] [-VlanTrunkRange <VlanRangeList>] [-PrivateVlanId <int>] [-WhatIf] 
                      [-Confirm] [<CommonParameters>], -VDSwitch <VDSwitch&#91;&#93;> [-DisableVlan] [-VlanId <int>] [-VlanTrunkRange <VlanRangeList>] [-Priva
                      teVlanId <int>] [-WhatIf] [-Confirm] [<CommonParameters>], -VDPort <VDPort&#91;&#93;> [-DisableVlan] [-VlanId <int>] [-VlanTrunkRange <V
                      lanRangeList>] [-PrivateVlanId <int>] [-WhatIf] [-Confirm] [<CommonParameters>]}
HelpUri             : http://www.vmware.com/support/developer/PowerCLI/PowerCLI60R1/html/Set-VDVlanConfiguration.html
DLL                 : C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Modules\VMware.VimAutomation.Vds\VMware.VimAutomation.Vds.Commands
                      .dll




PS C:\Users\osakanataro> 

ほんとに実行できたーーー
じゃぁ、この段階での「Get-Module」はどうなってるか確認してみると、ちゃんとVMware.VimAutomation.Vdsが読み込まれてる・・・
謎な動作をしてますね・・・

PS C:\Users\osakanataro> Get-Module

ModuleType Version    Name                                ExportedCommands                                                                            
---------- -------    ----                                ----------------                                                                            
Script     0.0        Initialize-VMware_VimAutomation_Vds                                                                                             
Script     1.0.0.0    ISE                                 {Get-IseSnippet, Import-IseSnippet, New-IseSnippet}                                         
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}                          
Manifest   3.0.0.0    Microsoft.PowerShell.Security       {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-AuthenticodeSignature...}   
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}                                   
Manifest   3.0.0.0    Microsoft.WSMan.Management          {Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan, Enable-WSManCredSSP...}             
Manifest   6.0.0.0    VMware.VimAutomation.Core                                                                                                       
Manifest   6.0.0.0    VMware.VimAutomation.Sdk                                                                                                        
Binary     6.0.0.0    VMware.VimAutomation.Vds            {Add-VDSwitchPhysicalNetworkAdapter, Add-VDSwitchVMHost, Export-VDPortGroup, Export-VDSwi...



PS C:\Users\osakanataro>