標準PowerShell cmdlets を使ってShipStation テーブルにアクセスして、CSV にエクスポート。
CData Cmdlets Module for ShipStation は、直感的なShipStation データ連携を提供する標準cmdlet です。 本記事では、ShipStation Cmdlets を使ったサンプルを提供します。
ShipStation への接続を設定
Use the BASIC Authentication standard to connect.
- Login to your ShipStation account
- Click on the settings icon in the upper right corner. A column menu will show up on the left
- Click Account -> API Settings
- On the API Settings page, note the API Key and API Secret.
Authenticating to ShipStation
- APIKey: Set this to the API key from the API settings page.
- APISecret: Set this to the Secret key from the API settings page.
$conn = Connect-ShipStation -APIKey "$APIKey" -APISecret "$APISecret"
ShipStation データを取得してCSV にパイプライン
次の手順で、Tags テーブルデータを取得して、結果をCSV ファイルにエクスポートします:
Select-ShipStation -Connection $conn -Table Tags | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myTagsData.csv -NoTypeInformation
このように、Select-ShipStation から取得した結果を、Select-Object cmdlet に流し、Export-Csv cmdlet に渡す前にいくつかのプロパティを除外しています。これは、CData Cmdlets が接続情報、テーブル、およびカラム情報が結果セットのそれぞれの"行"に挿入されるためです。それらの情報を表示したくない場合に、Export-Csv cmdlet に渡す前に除外を先に行い、それからCSV ファイルにエクスポートします。。
CData Cmdlets から、次のCmdlets にデータをパイプラインするところでは、接続、テーブル、カラムの情報が必要です。このように、CData Cmdlets でデータ連携をシンプルに構成できます。Cmdlets では、モジュールのインストール、接続プロパティの設定だけで、データ連携の構築を始めることができます。是非、CData PowerShell Cmdlets の無償試用版をダウンロードして、シンプルかつパワフルなデータ連携を体感してください。