POWERSHELL

構文
  1. UString = POWERSHELL( コマンド, [同期フラグ, 画面表示] )
引数
コマンド
POWERSHELLのコマンド
同期フラグ
FALSE
終了を待つ (デフォルト)
TRUE
待たずに戻る
画面表示
FALSE
POWERSHELL画面を表示しない (デフォルト)
TRUE
表示する
2
最小化状態で起動する
戻値
標準出力を返す (同期フラグがTrue、もしくは画面表示がTrue,2の場合は返しません)

プログラム実行例

PCをシャットダウンする(PowerShell)

POWERSHELL("Stop-Computer -Force")
  1. POWERSHELL
解説
  1. 1行目
    POWERSHELL("Stop-Computer -Force")

    Stop-Computerコマンドでコンピュータを停止する。

    Stop-Computer
    コンピュータをシャットダウンする。
    -Force
    コンピュータのシャットダウンを強制します。

PCを再起動する(PowerShell)

POWERSHELL("Restart-Computer -Force")
  1. POWERSHELL
解説
  1. 1行目
    POWERSHELL("Restart-Computer -Force")

    Stop-Computerコマンドでコンピュータを停止する。

    Restart-Computer
    コンピュータを再起動する。
    -Force
    再起動を強制する。

システムの起動時間を取得

PRINT TRIM(POWERSHELL("[Management.ManagementDateTimeConverter]::ToDateTime((Get-WmiObject Win32_OperatingSystem).LastBootUpTime)"))
  1. TRIM
  2. POWERSHELL
結果
2019年12月21日 15:53:56

IEオブジェクト(COMオブジェクト)のメンバー一覧を取得する

PRINT POWERSHELL("$ie = New-Object -ComObject InternetExplorer.Application;Get-Member -InputObject $ie")
  1. POWERSHELL
結果


TypeName: System.__ComObject#{d30c1661-cdaf-11d0-8a3e-00c04fc9e26e}

Name MemberType Definition
---- ---------- ----------
ClientToWindow Method void ClientToWindow (int, int)
ExecWB Method void ExecWB (OLECMDID, OLECMDEXECOPT, Variant, Variant)
GetProperty Method Variant GetProperty (string)
GoBack Method void GoBack ()
GoForward Method void GoForward ()
GoHome Method void GoHome ()
GoSearch Method void GoSearch ()
Navigate Method void Navigate (string, Variant, Variant, Variant, Variant)
Navigate2 Method void Navigate2 (Variant, Variant, Variant, Variant, Variant)
PutProperty Method void PutProperty (string, Variant)
QueryStatusWB Method OLECMDF QueryStatusWB (OLECMDID)
Quit Method void Quit ()
Refresh Method void Refresh ()
Refresh2 Method void Refresh2 (Variant)
ShowBrowserBar Method void ShowBrowserBar (Variant, Variant, Variant)
Stop Method void Stop ()
AddressBar Property bool AddressBar () {get} {set}
Application Property IDispatch Application () {get}
Busy Property bool Busy () {get}
Container Property IDispatch Container () {get}
Document Property IDispatch Document () {get}
FullName Property string FullName () {get}
FullScreen Property bool FullScreen () {get} {set}
Height Property int Height () {get} {set}
HWND Property int HWND () {get}
Left Property int Left () {get} {set}
LocationName Property string LocationName () {get}
LocationURL Property string LocationURL () {get}
MenuBar Property bool MenuBar () {get} {set}
Name Property string Name () {get}
Offline Property bool Offline () {get} {set}
Parent Property IDispatch Parent () {get}
Path Property string Path () {get}
ReadyState Property tagREADYSTATE ReadyState () {get}
RegisterAsBrowser Property bool RegisterAsBrowser () {get} {set}
RegisterAsDropTarget Property bool RegisterAsDropTarget () {get} {set}
Resizable Property bool Resizable () {get} {set}
Silent Property bool Silent () {get} {set}
StatusBar Property bool StatusBar () {get} {set}
StatusText Property string StatusText () {get} {set}
TheaterMode Property bool TheaterMode () {get} {set}
ToolBar Property int ToolBar () {get} {set}
Top Property int Top () {get} {set}
TopLevelContainer Property bool TopLevelContainer () {get}
Type Property string Type () {get}
Visible Property bool Visible () {get} {set}
Width Property int Width () {get} {set}



Shellオブジェクト(COMオブジェクト)のメンバー一覧を取得する

PRINT POWERSHELL("$shell = New-Object -ComObject Shell.Application;Get-Member -InputObject $shell")
  1. POWERSHELL
結果


TypeName: System.__ComObject#{286e6f1b-7113-4355-9562-96b7e9d64c54}

Name MemberType Definition
---- ---------- ----------
AddToRecent Method void AddToRecent (Variant, string)
BrowseForFolder Method Folder BrowseForFolder (int, string, int, Variant)
CanStartStopService Method Variant CanStartStopService (string)
CascadeWindows Method void CascadeWindows ()
ControlPanelItem Method void ControlPanelItem (string)
EjectPC Method void EjectPC ()
Explore Method void Explore (Variant)
ExplorerPolicy Method Variant ExplorerPolicy (string)
FileRun Method void FileRun ()
FindComputer Method void FindComputer ()
FindFiles Method void FindFiles ()
FindPrinter Method void FindPrinter (string, string, string)
GetSetting Method bool GetSetting (int)
GetSystemInformation Method Variant GetSystemInformation (string)
Help Method void Help ()
IsRestricted Method int IsRestricted (string, string)
IsServiceRunning Method Variant IsServiceRunning (string)
MinimizeAll Method void MinimizeAll ()
NameSpace Method Folder NameSpace (Variant)
Open Method void Open (Variant)
RefreshMenu Method void RefreshMenu ()
SearchCommand Method void SearchCommand ()
ServiceStart Method Variant ServiceStart (string, Variant)
ServiceStop Method Variant ServiceStop (string, Variant)
SetTime Method void SetTime ()
ShellExecute Method void ShellExecute (string, Variant, Variant, Variant, Variant)
ShowBrowserBar Method Variant ShowBrowserBar (string, Variant)
ShutdownWindows Method void ShutdownWindows ()
Suspend Method void Suspend ()
TileHorizontally Method void TileHorizontally ()
TileVertically Method void TileVertically ()
ToggleDesktop Method void ToggleDesktop ()
TrayProperties Method void TrayProperties ()
UndoMinimizeALL Method void UndoMinimizeALL ()
Windows Method IDispatch Windows ()
WindowsSecurity Method void WindowsSecurity ()
WindowSwitcher Method void WindowSwitcher ()
Application Property IDispatch Application () {get}
Parent Property IDispatch Parent () {get}