Skip to content

原文(日本語に翻訳)

WindowsのPowerShellツールをオプトインプレビューとして追加。

原文(英語)

Added PowerShell tool for Windows as an opt-in preview. Learn more at https://code.claude.com/docs/en/tools-reference#powershell-tool

概要

Claude CodeにWindowsネイティブのPowerShellツールがオプトインプレビューとして追加されました。これにより、WindowsユーザーはBashの代わりにPowerShellを使ってシステム操作やスクリプト実行ができるようになります。現時点ではプレビュー版のため、明示的に有効化する必要があります。

基本的な使い方

PowerShellツールを有効化するには、settings.json でオプトイン設定を行います。

json
{
  "enabledTools": ["powershell"]
}

有効化後、ClaudeはPowerShellコマンドを実行できるようになります。

powershell
# ディレクトリ一覧を取得
Get-ChildItem -Path C:\Users\username\Documents

# ファイル内容を確認
Get-Content -Path .\config.txt

# プロセス一覧
Get-Process | Where-Object { $_.CPU -gt 10 }

実践例

Windowsシステム管理

powershell
# Windowsサービスの状態確認
Get-Service | Where-Object { $_.Status -eq "Stopped" }

# システム情報取得
Get-ComputerInfo | Select-Object WindowsProductName, TotalPhysicalMemory

# イベントログ確認
Get-EventLog -LogName System -Newest 10 -EntryType Error

.NETプロジェクトのビルドと管理

powershell
# NuGetパッケージ復元
dotnet restore

# プロジェクトビルド
dotnet build --configuration Release

# テスト実行
dotnet test --no-build

ファイル操作とデータ処理

powershell
# CSVファイルのインポートと処理
$data = Import-Csv -Path .\data.csv
$data | Where-Object { $_.Status -eq "Active" } | Export-Csv -Path .\active.csv

# レジストリ操作
Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion"

Azure/クラウド連携

powershell
# Azure CLIコマンド(Az PowerShellモジュール使用)
Get-AzResourceGroup | Select-Object ResourceGroupName, Location

# AWS PowerShellコマンド
Get-S3Bucket

注意点

  • プレビュー版: 現時点ではオプトイン機能のため、本番環境での使用は慎重に検討してください
  • Windows専用: このツールはWindowsプラットフォームでのみ利用可能です。macOSやLinuxでは使用できません
  • セキュリティポリシー: PowerShellの実行ポリシー(ExecutionPolicy)が制限されている場合、一部のスクリプトが実行できない場合があります
  • Bashとの併用: WindowsでもBashツールは引き続き利用可能です(WSL経由)。用途に応じて使い分けてください

関連情報