Power Automate Desktop「ループを使わないリスト内の検索」

## 概要

Power Automate Desktop（以下PAD）のフロー内で配列データ（リスト）から、目的データのインデックスをループを使わずに検索します。
PADのループアクションを使用する場合に比べて速度向上が期待できます。
配列内の検索にPython Scriptの実行アクション、PowerShellスクリプトの実行アクションを使った例をそれぞれ示します。
![](indexsearch.gif)![indexsearch.gif](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/680039/4e364791-a526-79d2-ccf4-0aa391f45afe.gif)

## 注意

* Power Automate Desktop　2.8.73.21119
* 2021年5月の情報です。
* 一意のインデックスを検索するフローですのでご注意ください。
* 自己責任でお願いいたします。

## フロー

Python、PowerShellの各アクションにリストを渡す場合、PAD側のリスト変数をそのまま渡すことができません。テキストデータとして渡し、スクリプト内で配列データとして再構成します。また出力側もテキストになるのでインデックスとして扱うためには数値に変換します。

### Pythonスクリプトの実行アクションを使用した例

![](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/680039/01e9346e-7755-b67b-9642-0dbc23009ce8.png)


1. 変数の設定
   2列X1200行のデータテーブルをサンプルとしてハードコードしてあります。Name列はa-d各001~300です。
   ![](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/680039/6beef412-9452-59fe-a544-c1e94b035bb1.png)

   ![](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/680039/391ac78a-e251-a0b6-d700-a98d617214ab.png)

2. 入力ダイアログの表示
   適宜メッセージをいれます。変数名デフォルトです。
   ![](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/680039/06df64ac-960f-1d1c-c9dc-79fb2578dae9.png)

3. データテーブル列をリストに取得
   検索する列（name列）をリストにします。
   ![](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/680039/65863e57-1b6f-3772-c0f5-7659e5649778.png)

4. テキストの結合
   列データをテキストに変換します。区切りを```','```とするのがポイントです。
   ![](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/680039/1f7ed9b6-7bfb-d510-2757-00da061ff098.png)

   ![](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/680039/b53f0a35-611f-f435-6509-51a2d4adc128.png)

   先頭と最後部にシングルクオーテーションが抜けた状態でテキスト化されます。
5. Pythonスクリプトの実行
   Python内で```list =['%JoinedText%']```とすることで、リストを再構成します。
   index関数でリスト内を検索します。```print (list.index('%UserInput%'))```
   ![](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/680039/ef21d54d-3b83-d3a8-9d6d-46e41c34a4ac.png)

6. テキストの解析
   %PythonScriptOutput%は余分なデータが含まれたテキストなので数字部分をこのアクションで抜きだします。「テキストのトリミング」→「テキストを数値に変換」は不可です。
   ![](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/680039/7888c931-a10d-fcbd-2f8d-6056dc23a815.png)

7. IF
   検索値が該当しない場合の処理です。
   ![](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/680039/1b6424df-79a5-8221-23bc-dc368a409d86.png)

8. 変数の設定
   ![](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/680039/bf3580a6-a589-78c0-f3f1-f28960f3e1f2.png)

9.  移動先
    ![](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/680039/a532a23d-253d-0a9a-4c44-92103571b43a.png)

10. End
11. テキストを数値に変換
    ![](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/680039/f48b86d8-0981-ff85-68f2-c998cedac5bf.png)

12. 変数の設定
    検索したインデックスで行データを抜き出し。
13. ラベル
    ![](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/680039/4f8d81bb-18b8-5bae-039a-fb0c78efb17e.png)

14. メッセージを表示
    ![](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/680039/4c2c0fe6-f81e-b0c9-f4f1-43c214bd9bc6.png)


#### サンプルデータ

```r:PowerAutomateDesktop

SET DataTable TO { ^['name', 'value'], ['a001', 15.0], ['b001', 34.0], ['c001', 7.0], ['d001', 14.0], ['a002', 10.0], ['b002', 7.0], ['c002', 4.0], ['d002', 0.999999999999996], ['a003', -2.0], ['b003', -5.0], ['c003', -8.0], ['d003', -11.0], ['a004', -14.0], ['b004', -17.0], ['c004', -20.0], ['d004', -23.0], ['a005', -26.0], ['b005', -29.0], ['c005', -32.0], ['d005', -35.0], ['a006', -38.0], ['b006', -41.0], ['c006', -44.0], ['d006', -47.0], ['a007', -50.0], ['b007', -53.0], ['c007', -56.0], ['d007', -59.0], ['a008', -62.0], ['b008', -65.0], ['c008', -68.0], ['d008', -71.0], ['a009', -74.0], ['b009', -77.0], ['c009', -80.0], ['d009', -83.0], ['a010', -86.0], ['b010', -89.0], ['c010', -92.0], ['d010', -95.0], ['a011', -98.0], ['b011', -101.0], ['c011', -104.0], ['d011', -107.0], ['a012', -110.0], ['b012', -113.0], ['c012', -116.0], ['d012', -119.0], ['a013', -122.0], ['b013', -125.0], ['c013', -128.0], ['d013', -131.0], ['a014', -134.0], ['b014', -137.0], ['c014', -140.0], ['d014', -143.0], ['a015', -146.0], ['b015', -149.0], ['c015', -152.0], ['d015', -155.0], ['a016', -158.0], ['b016', -161.0], ['c016', -164.0], ['d016', -167.0], ['a017', -170.0], ['b017', -173.0], ['c017', -176.0], ['d017', -179.0], ['a018', -182.0], ['b018', -185.0], ['c018', -188.0], ['d018', -191.0], ['a019', -194.0], ['b019', -197.0], ['c019', -200.0], ['d019', -203.0], ['a020', -206.0], ['b020', -209.0], ['c020', -212.0], ['d020', -215.0], ['a021', -218.0], ['b021', -221.0], ['c021', -224.0], ['d021', -227.0], ['a022', -230.0], ['b022', -233.0], ['c022', -236.0], ['d022', -239.0], ['a023', -242.0], ['b023', -245.0], ['c023', -248.0], ['d023', -251.0], ['a024', -254.0], ['b024', -257.0], ['c024', -260.0], ['d024', -263.0], ['a025', -266.0], ['b025', -269.0], ['c025', -272.0], ['d025', -275.0], ['a026', -278.0], ['b026', -281.0], ['c026', -284.0], ['d026', -287.0], ['a027', -290.0], ['b027', -293.0], ['c027', -296.0], ['d027', -299.0], ['a028', -302.0], ['b028', -305.0], ['c028', -308.0], ['d028', -311.0], ['a029', -314.0], ['b029', -317.0], ['c029', -320.0], ['d029', -323.0], ['a030', -326.0], ['b030', -329.0], ['c030', -332.0], ['d030', -335.0], ['a031', -338.0], ['b031', -341.0], ['c031', -344.0], ['d031', -347.0], ['a032', -350.0], ['b032', -353.0], ['c032', -356.0], ['d032', -359.0], ['a033', -362.0], ['b033', -365.0], ['c033', -368.0], ['d033', -371.0], ['a034', -374.0], ['b034', -377.0], ['c034', -380.0], ['d034', -383.0], ['a035', -386.0], ['b035', -389.0], ['c035', -392.0], ['d035', -395.0], ['a036', -398.0], ['b036', -401.0], ['c036', -404.0], ['d036', -407.0], ['a037', -410.0], ['b037', -413.0], ['c037', -416.0], ['d037', -419.0], ['a038', -422.0], ['b038', -425.0], ['c038', -428.0], ['d038', -431.0], ['a039', -434.0], ['b039', -437.0], ['c039', -440.0], ['d039', -443.0], ['a040', -446.0], ['b040', -449.0], ['c040', -452.0], ['d040', -455.0], ['a041', -458.0], ['b041', -461.0], ['c041', -464.0], ['d041', -467.0], ['a042', -470.0], ['b042', -473.0], ['c042', -476.0], ['d042', -479.0], ['a043', -482.0], ['b043', -485.0], ['c043', -488.0], ['d043', -491.0], ['a044', -494.0], ['b044', -497.0], ['c044', -500.0], ['d044', -503.0], ['a045', -506.0], ['b045', -509.0], ['c045', -512.0], ['d045', -515.0], ['a046', -518.0], ['b046', -521.0], ['c046', -524.0], ['d046', -527.0], ['a047', -530.0], ['b047', -533.0], ['c047', -536.0], ['d047', -539.0], ['a048', -542.0], ['b048', -545.0], ['c048', -548.0], ['d048', -551.0], ['a049', -554.0], ['b049', -557.0], ['c049', -560.0], ['d049', -563.0], ['a050', -566.0], ['b050', -569.0], ['c050', -572.0], ['d050', -575.0], ['a051', -578.0], ['b051', -581.0], ['c051', -584.0], ['d051', -587.0], ['a052', -590.0], ['b052', -593.0], ['c052', -596.0], ['d052', -599.0], ['a053', -602.0], ['b053', -605.0], ['c053', -608.0], ['d053', -611.0], ['a054', -614.0], ['b054', -617.0], ['c054', -620.0], ['d054', -623.0], ['a055', -626.0], ['b055', -629.0], ['c055', -632.0], ['d055', -635.0], ['a056', -638.0], ['b056', -641.0], ['c056', -644.0], ['d056', -647.0], ['a057', -650.0], ['b057', -653.0], ['c057', -656.0], ['d057', -659.0], ['a058', -662.0], ['b058', -665.0], ['c058', -668.0], ['d058', -671.0], ['a059', -674.0], ['b059', -677.0], ['c059', -680.0], ['d059', -683.0], ['a060', -686.0], ['b060', -689.0], ['c060', -692.0], ['d060', -695.0], ['a061', -698.0], ['b061', -701.0], ['c061', -704.0], ['d061', -707.0], ['a062', -710.0], ['b062', -713.0], ['c062', -716.0], ['d062', -719.0], ['a063', -722.0], ['b063', -725.0], ['c063', -728.0], ['d063', -731.0], ['a064', -734.0], ['b064', -737.0], ['c064', -740.0], ['d064', -743.0], ['a065', -746.0], ['b065', -749.0], ['c065', -752.0], ['d065', -755.0], ['a066', -758.0], ['b066', -761.0], ['c066', -764.0], ['d066', -767.0], ['a067', -770.0], ['b067', -773.0], ['c067', -776.0], ['d067', -779.0], ['a068', -782.0], ['b068', -785.0], ['c068', -788.0], ['d068', -791.0], ['a069', -794.0], ['b069', -797.0], ['c069', -800.0], ['d069', -803.0], ['a070', -806.0], ['b070', -809.0], ['c070', -812.0], ['d070', -815.0], ['a071', -818.0], ['b071', -821.0], ['c071', -824.0], ['d071', -827.0], ['a072', -830.0], ['b072', -833.0], ['c072', -836.0], ['d072', -839.0], ['a073', -842.0], ['b073', -845.0], ['c073', -848.0], ['d073', -851.0], ['a074', -854.0], ['b074', -857.0], ['c074', -860.0], ['d074', -863.0], ['a075', -866.0], ['b075', -869.0], ['c075', -872.0], ['d075', -875.0], ['a076', -878.0], ['b076', -881.0], ['c076', -884.0], ['d076', -887.0], ['a077', -890.0], ['b077', -893.0], ['c077', -896.0], ['d077', -899.0], ['a078', -902.0], ['b078', -905.0], ['c078', -908.0], ['d078', -911.0], ['a079', -914.0], ['b079', -917.0], ['c079', -920.0], ['d079', -923.0], ['a080', -926.0], ['b080', -929.0], ['c080', -932.0], ['d080', -935.0], ['a081', -938.0], ['b081', -941.0], ['c081', -944.0], ['d081', -947.0], ['a082', -950.0], ['b082', -953.0], ['c082', -956.0], ['d082', -959.0], ['a083', -962.0], ['b083', -965.0], ['c083', -968.0], ['d083', -971.0], ['a084', -974.0], ['b084', -977.0], ['c084', -980.0], ['d084', -983.0], ['a085', -986.0], ['b085', -989.0], ['c085', -992.0], ['d085', -995.0], ['a086', -998.0], ['b086', -1001.0], ['c086', -1004.0], ['d086', -1007.0], ['a087', -1010.0], ['b087', -1013.0], ['c087', -1016.0], ['d087', -1019.0], ['a088', -1022.0], ['b088', -1025.0], ['c088', -1028.0], ['d088', -1031.0], ['a089', -1034.0], ['b089', -1037.0], ['c089', -1040.0], ['d089', -1043.0], ['a090', -1046.0], ['b090', -1049.0], ['c090', -1052.0], ['d090', -1055.0], ['a091', -1058.0], ['b091', -1061.0], ['c091', -1064.0], ['d091', -1067.0], ['a092', -1070.0], ['b092', -1073.0], ['c092', -1076.0], ['d092', -1079.0], ['a093', -1082.0], ['b093', -1085.0], ['c093', -1088.0], ['d093', -1091.0], ['a094', -1094.0], ['b094', -1097.0], ['c094', -1100.0], ['d094', -1103.0], ['a095', -1106.0], ['b095', -1109.0], ['c095', -1112.0], ['d095', -1115.0], ['a096', -1118.0], ['b096', -1121.0], ['c096', -1124.0], ['d096', -1127.0], ['a097', -1130.0], ['b097', -1133.0], ['c097', -1136.0], ['d097', -1139.0], ['a098', -1142.0], ['b098', -1145.0], ['c098', -1148.0], ['d098', -1151.0], ['a099', -1154.0], ['b099', -1157.0], ['c099', -1160.0], ['d099', -1163.0], ['a100', -1166.0], ['b100', -1169.0], ['c100', -1172.0], ['d100', -1175.0], ['a101', -1178.0], ['b101', -1181.0], ['c101', -1184.0], ['d101', -1187.0], ['a102', -1190.0], ['b102', -1193.0], ['c102', -1196.0], ['d102', -1199.0], ['a103', -1202.0], ['b103', -1205.0], ['c103', -1208.0], ['d103', -1211.0], ['a104', -1214.0], ['b104', -1217.0], ['c104', -1220.0], ['d104', -1223.0], ['a105', -1226.0], ['b105', -1229.0], ['c105', -1232.0], ['d105', -1235.0], ['a106', -1238.0], ['b106', -1241.0], ['c106', -1244.0], ['d106', -1247.0], ['a107', -1250.0], ['b107', -1253.0], ['c107', -1256.0], ['d107', -1259.0], ['a108', -1262.0], ['b108', -1265.0], ['c108', -1268.0], ['d108', -1271.0], ['a109', -1274.0], ['b109', -1277.0], ['c109', -1280.0], ['d109', -1283.0], ['a110', -1286.0], ['b110', -1289.0], ['c110', -1292.0], ['d110', -1295.0], ['a111', -1298.0], ['b111', -1301.0], ['c111', -1304.0], ['d111', -1307.0], ['a112', -1310.0], ['b112', -1313.0], ['c112', -1316.0], ['d112', -1319.0], ['a113', -1322.0], ['b113', -1325.0], ['c113', -1328.0], ['d113', -1331.0], ['a114', -1334.0], ['b114', -1337.0], ['c114', -1340.0], ['d114', -1343.0], ['a115', -1346.0], ['b115', -1349.0], ['c115', -1352.0], ['d115', -1355.0], ['a116', -1358.0], ['b116', -1361.0], ['c116', -1364.0], ['d116', -1367.0], ['a117', -1370.0], ['b117', -1373.0], ['c117', -1376.0], ['d117', -1379.0], ['a118', -1382.0], ['b118', -1385.0], ['c118', -1388.0], ['d118', -1391.0], ['a119', -1394.0], ['b119', -1397.0], ['c119', -1400.0], ['d119', -1403.0], ['a120', -1406.0], ['b120', -1409.0], ['c120', -1412.0], ['d120', -1415.0], ['a121', -1418.0], ['b121', -1421.0], ['c121', -1424.0], ['d121', -1427.0], ['a122', -1430.0], ['b122', -1433.0], ['c122', -1436.0], ['d122', -1439.0], ['a123', -1442.0], ['b123', -1445.0], ['c123', -1448.0], ['d123', -1451.0], ['a124', -1454.0], ['b124', -1457.0], ['c124', -1460.0], ['d124', -1463.0], ['a125', -1466.0], ['b125', -1469.0], ['c125', -1472.0], ['d125', -1475.0], ['a126', -1478.0], ['b126', -1481.0], ['c126', -1484.0], ['d126', -1487.0], ['a127', -1490.0], ['b127', -1493.0], ['c127', -1496.0], ['d127', -1499.0], ['a128', -1502.0], ['b128', -1505.0], ['c128', -1508.0], ['d128', -1511.0], ['a129', -1514.0], ['b129', -1517.0], ['c129', -1520.0], ['d129', -1523.0], ['a130', -1526.0], ['b130', -1529.0], ['c130', -1532.0], ['d130', -1535.0], ['a131', -1538.0], ['b131', -1541.0], ['c131', -1544.0], ['d131', -1547.0], ['a132', -1550.0], ['b132', -1553.0], ['c132', -1556.0], ['d132', -1559.0], ['a133', -1562.0], ['b133', -1565.0], ['c133', -1568.0], ['d133', -1571.0], ['a134', -1574.0], ['b134', -1577.0], ['c134', -1580.0], ['d134', -1583.0], ['a135', -1586.0], ['b135', -1589.0], ['c135', -1592.0], ['d135', -1595.0], ['a136', -1598.0], ['b136', -1601.0], ['c136', -1604.0], ['d136', -1607.0], ['a137', -1610.0], ['b137', -1613.0], ['c137', -1616.0], ['d137', -1619.0], ['a138', -1622.0], ['b138', -1625.0], ['c138', -1628.0], ['d138', -1631.0], ['a139', -1634.0], ['b139', -1637.0], ['c139', -1640.0], ['d139', -1643.0], ['a140', -1646.0], ['b140', -1649.0], ['c140', -1652.0], ['d140', -1655.0], ['a141', -1658.0], ['b141', -1661.0], ['c141', -1664.0], ['d141', -1667.0], ['a142', -1670.0], ['b142', -1673.0], ['c142', -1676.0], ['d142', -1679.0], ['a143', -1682.0], ['b143', -1685.0], ['c143', -1688.0], ['d143', -1691.0], ['a144', -1694.0], ['b144', -1697.0], ['c144', -1700.0], ['d144', -1703.0], ['a145', -1706.0], ['b145', -1709.0], ['c145', -1712.0], ['d145', -1715.0], ['a146', -1718.0], ['b146', -1721.0], ['c146', -1724.0], ['d146', -1727.0], ['a147', -1730.0], ['b147', -1733.0], ['c147', -1736.0], ['d147', -1739.0], ['a148', -1742.0], ['b148', -1745.0], ['c148', -1748.0], ['d148', -1751.0], ['a149', -1754.0], ['b149', -1757.0], ['c149', -1760.0], ['d149', -1763.0], ['a150', -1766.0], ['b150', -1769.0], ['c150', -1772.0], ['d150', -1775.0], ['a151', -1778.0], ['b151', -1781.0], ['c151', -1784.0], ['d151', -1787.0], ['a152', -1790.0], ['b152', -1793.0], ['c152', -1796.0], ['d152', -1799.0], ['a153', -1802.0], ['b153', -1805.0], ['c153', -1808.0], ['d153', -1811.0], ['a154', -1814.0], ['b154', -1817.0], ['c154', -1820.0], ['d154', -1823.0], ['a155', -1826.0], ['b155', -1829.0], ['c155', -1832.0], ['d155', -1835.0], ['a156', -1838.0], ['b156', -1841.0], ['c156', -1844.0], ['d156', -1847.0], ['a157', -1850.0], ['b157', -1853.0], ['c157', -1856.0], ['d157', -1859.0], ['a158', -1862.0], ['b158', -1865.0], ['c158', -1868.0], ['d158', -1871.0], ['a159', -1874.0], ['b159', -1877.0], ['c159', -1880.0], ['d159', -1883.0], ['a160', -1886.0], ['b160', -1889.0], ['c160', -1892.0], ['d160', -1895.0], ['a161', -1898.0], ['b161', -1901.0], ['c161', -1904.0], ['d161', -1907.0], ['a162', -1910.0], ['b162', -1913.0], ['c162', -1916.0], ['d162', -1919.0], ['a163', -1922.0], ['b163', -1925.0], ['c163', -1928.0], ['d163', -1931.0], ['a164', -1934.0], ['b164', -1937.0], ['c164', -1940.0], ['d164', -1943.0], ['a165', -1946.0], ['b165', -1949.0], ['c165', -1952.0], ['d165', -1955.0], ['a166', -1958.0], ['b166', -1961.0], ['c166', -1964.0], ['d166', -1967.0], ['a167', -1970.0], ['b167', -1973.0], ['c167', -1976.0], ['d167', -1979.0], ['a168', -1982.0], ['b168', -1985.0], ['c168', -1988.0], ['d168', -1991.0], ['a169', -1994.0], ['b169', -1997.0], ['c169', -2000.0], ['d169', -2003.0], ['a170', -2006.0], ['b170', -2009.0], ['c170', -2012.0], ['d170', -2015.0], ['a171', -2018.0], ['b171', -2021.0], ['c171', -2024.0], ['d171', -2027.0], ['a172', -2030.0], ['b172', -2033.0], ['c172', -2036.0], ['d172', -2039.0], ['a173', -2042.0], ['b173', -2045.0], ['c173', -2048.0], ['d173', -2051.0], ['a174', -2054.0], ['b174', -2057.0], ['c174', -2060.0], ['d174', -2063.0], ['a175', -2066.0], ['b175', -2069.0], ['c175', -2072.0], ['d175', -2075.0], ['a176', -2078.0], ['b176', -2081.0], ['c176', -2084.0], ['d176', -2087.0], ['a177', -2090.0], ['b177', -2093.0], ['c177', -2096.0], ['d177', -2099.0], ['a178', -2102.0], ['b178', -2105.0], ['c178', -2108.0], ['d178', -2111.0], ['a179', -2114.0], ['b179', -2117.0], ['c179', -2120.0], ['d179', -2123.0], ['a180', -2126.0], ['b180', -2129.0], ['c180', -2132.0], ['d180', -2135.0], ['a181', -2138.0], ['b181', -2141.0], ['c181', -2144.0], ['d181', -2147.0], ['a182', -2150.0], ['b182', -2153.0], ['c182', -2156.0], ['d182', -2159.0], ['a183', -2162.0], ['b183', -2165.0], ['c183', -2168.0], ['d183', -2171.0], ['a184', -2174.0], ['b184', -2177.0], ['c184', -2180.0], ['d184', -2183.0], ['a185', -2186.0], ['b185', -2189.0], ['c185', -2192.0], ['d185', -2195.0], ['a186', -2198.0], ['b186', -2201.0], ['c186', -2204.0], ['d186', -2207.0], ['a187', -2210.0], ['b187', -2213.0], ['c187', -2216.0], ['d187', -2219.0], ['a188', -2222.0], ['b188', -2225.0], ['c188', -2228.0], ['d188', -2231.0], ['a189', -2234.0], ['b189', -2237.0], ['c189', -2240.0], ['d189', -2243.0], ['a190', -2246.0], ['b190', -2249.0], ['c190', -2252.0], ['d190', -2255.0], ['a191', -2258.0], ['b191', -2261.0], ['c191', -2264.0], ['d191', -2267.0], ['a192', -2270.0], ['b192', -2273.0], ['c192', -2276.0], ['d192', -2279.0], ['a193', -2282.0], ['b193', -2285.0], ['c193', -2288.0], ['d193', -2291.0], ['a194', -2294.0], ['b194', -2297.0], ['c194', -2300.0], ['d194', -2303.0], ['a195', -2306.0], ['b195', -2309.0], ['c195', -2312.0], ['d195', -2315.0], ['a196', -2318.0], ['b196', -2321.0], ['c196', -2324.0], ['d196', -2327.0], ['a197', -2330.0], ['b197', -2333.0], ['c197', -2336.0], ['d197', -2339.0], ['a198', -2342.0], ['b198', -2345.0], ['c198', -2348.0], ['d198', -2351.0], ['a199', -2354.0], ['b199', -2357.0], ['c199', -2360.0], ['d199', -2363.0], ['a200', -2366.0], ['b200', -2369.0], ['c200', -2372.0], ['d200', -2375.0], ['a201', -2378.0], ['b201', -2381.0], ['c201', -2384.0], ['d201', -2387.0], ['a202', -2390.0], ['b202', -2393.0], ['c202', -2396.0], ['d202', -2399.0], ['a203', -2402.0], ['b203', -2405.0], ['c203', -2408.0], ['d203', -2411.0], ['a204', -2414.0], ['b204', -2417.0], ['c204', -2420.0], ['d204', -2423.0], ['a205', -2426.0], ['b205', -2429.0], ['c205', -2432.0], ['d205', -2435.0], ['a206', -2438.0], ['b206', -2441.0], ['c206', -2444.0], ['d206', -2447.0], ['a207', -2450.0], ['b207', -2453.0], ['c207', -2456.0], ['d207', -2459.0], ['a208', -2462.0], ['b208', -2465.0], ['c208', -2468.0], ['d208', -2471.0], ['a209', -2474.0], ['b209', -2477.0], ['c209', -2480.0], ['d209', -2483.0], ['a210', -2486.0], ['b210', -2489.0], ['c210', -2492.0], ['d210', -2495.0], ['a211', -2498.0], ['b211', -2501.0], ['c211', -2504.0], ['d211', -2507.0], ['a212', -2510.0], ['b212', -2513.0], ['c212', -2516.0], ['d212', -2519.0], ['a213', -2522.0], ['b213', -2525.0], ['c213', -2528.0], ['d213', -2531.0], ['a214', -2534.0], ['b214', -2537.0], ['c214', -2540.0], ['d214', -2543.0], ['a215', -2546.0], ['b215', -2549.0], ['c215', -2552.0], ['d215', -2555.0], ['a216', -2558.0], ['b216', -2561.0], ['c216', -2564.0], ['d216', -2567.0], ['a217', -2570.0], ['b217', -2573.0], ['c217', -2576.0], ['d217', -2579.0], ['a218', -2582.0], ['b218', -2585.0], ['c218', -2588.0], ['d218', -2591.0], ['a219', -2594.0], ['b219', -2597.0], ['c219', -2600.0], ['d219', -2603.0], ['a220', -2606.0], ['b220', -2609.0], ['c220', -2612.0], ['d220', -2615.0], ['a221', -2618.0], ['b221', -2621.0], ['c221', -2624.0], ['d221', -2627.0], ['a222', -2630.0], ['b222', -2633.0], ['c222', -2636.0], ['d222', -2639.0], ['a223', -2642.0], ['b223', -2645.0], ['c223', -2648.0], ['d223', -2651.0], ['a224', -2654.0], ['b224', -2657.0], ['c224', -2660.0], ['d224', -2663.0], ['a225', -2666.0], ['b225', -2669.0], ['c225', -2672.0], ['d225', -2675.0], ['a226', -2678.0], ['b226', -2681.0], ['c226', -2684.0], ['d226', -2687.0], ['a227', -2690.0], ['b227', -2693.0], ['c227', -2696.0], ['d227', -2699.0], ['a228', -2702.0], ['b228', -2705.0], ['c228', -2708.0], ['d228', -2711.0], ['a229', -2714.0], ['b229', -2717.0], ['c229', -2720.0], ['d229', -2723.0], ['a230', -2726.0], ['b230', -2729.0], ['c230', -2732.0], ['d230', -2735.0], ['a231', -2738.0], ['b231', -2741.0], ['c231', -2744.0], ['d231', -2747.0], ['a232', -2750.0], ['b232', -2753.0], ['c232', -2756.0], ['d232', -2759.0], ['a233', -2762.0], ['b233', -2765.0], ['c233', -2768.0], ['d233', -2771.0], ['a234', -2774.0], ['b234', -2777.0], ['c234', -2780.0], ['d234', -2783.0], ['a235', -2786.0], ['b235', -2789.0], ['c235', -2792.0], ['d235', -2795.0], ['a236', -2798.0], ['b236', -2801.0], ['c236', -2804.0], ['d236', -2807.0], ['a237', -2810.0], ['b237', -2813.0], ['c237', -2816.0], ['d237', -2819.0], ['a238', -2822.0], ['b238', -2825.0], ['c238', -2828.0], ['d238', -2831.0], ['a239', -2834.0], ['b239', -2837.0], ['c239', -2840.0], ['d239', -2843.0], ['a240', -2846.0], ['b240', -2849.0], ['c240', -2852.0], ['d240', -2855.0], ['a241', -2858.0], ['b241', -2861.0], ['c241', -2864.0], ['d241', -2867.0], ['a242', -2870.0], ['b242', -2873.0], ['c242', -2876.0], ['d242', -2879.0], ['a243', -2882.0], ['b243', -2885.0], ['c243', -2888.0], ['d243', -2891.0], ['a244', -2894.0], ['b244', -2897.0], ['c244', -2900.0], ['d244', -2903.0], ['a245', -2906.0], ['b245', -2909.0], ['c245', -2912.0], ['d245', -2915.0], ['a246', -2918.0], ['b246', -2921.0], ['c246', -2924.0], ['d246', -2927.0], ['a247', -2930.0], ['b247', -2933.0], ['c247', -2936.0], ['d247', -2939.0], ['a248', -2942.0], ['b248', -2945.0], ['c248', -2948.0], ['d248', -2951.0], ['a249', -2954.0], ['b249', -2957.0], ['c249', -2960.0], ['d249', -2963.0], ['a250', -2966.0], ['b250', -2969.0], ['c250', -2972.0], ['d250', -2975.0], ['a251', -2978.0], ['b251', -2981.0], ['c251', -2984.0], ['d251', -2987.0], ['a252', -2990.0], ['b252', -2993.0], ['c252', -2996.0], ['d252', -2999.0], ['a253', -3002.0], ['b253', -3005.0], ['c253', -3008.0], ['d253', -3011.0], ['a254', -3014.0], ['b254', -3017.0], ['c254', -3020.0], ['d254', -3023.0], ['a255', -3026.0], ['b255', -3029.0], ['c255', -3032.0], ['d255', -3035.0], ['a256', -3038.0], ['b256', -3041.0], ['c256', -3044.0], ['d256', -3047.0], ['a257', -3050.0], ['b257', -3053.0], ['c257', -3056.0], ['d257', -3059.0], ['a258', -3062.0], ['b258', -3065.0], ['c258', -3068.0], ['d258', -3071.0], ['a259', -3074.0], ['b259', -3077.0], ['c259', -3080.0], ['d259', -3083.0], ['a260', -3086.0], ['b260', -3089.0], ['c260', -3092.0], ['d260', -3095.0], ['a261', -3098.0], ['b261', -3101.0], ['c261', -3104.0], ['d261', -3107.0], ['a262', -3110.0], ['b262', -3113.0], ['c262', -3116.0], ['d262', -3119.0], ['a263', -3122.0], ['b263', -3125.0], ['c263', -3128.0], ['d263', -3131.0], ['a264', -3134.0], ['b264', -3137.0], ['c264', -3140.0], ['d264', -3143.0], ['a265', -3146.0], ['b265', -3149.0], ['c265', -3152.0], ['d265', -3155.0], ['a266', -3158.0], ['b266', -3161.0], ['c266', -3164.0], ['d266', -3167.0], ['a267', -3170.0], ['b267', -3173.0], ['c267', -3176.0], ['d267', -3179.0], ['a268', -3182.0], ['b268', -3185.0], ['c268', -3188.0], ['d268', -3191.0], ['a269', -3194.0], ['b269', -3197.0], ['c269', -3200.0], ['d269', -3203.0], ['a270', -3206.0], ['b270', -3209.0], ['c270', -3212.0], ['d270', -3215.0], ['a271', -3218.0], ['b271', -3221.0], ['c271', -3224.0], ['d271', -3227.0], ['a272', -3230.0], ['b272', -3233.0], ['c272', -3236.0], ['d272', -3239.0], ['a273', -3242.0], ['b273', -3245.0], ['c273', -3248.0], ['d273', -3251.0], ['a274', -3254.0], ['b274', -3257.0], ['c274', -3260.0], ['d274', -3263.0], ['a275', -3266.0], ['b275', -3269.0], ['c275', -3272.0], ['d275', -3275.0], ['a276', -3278.0], ['b276', -3281.0], ['c276', -3284.0], ['d276', -3287.0], ['a277', -3290.0], ['b277', -3293.0], ['c277', -3296.0], ['d277', -3299.0], ['a278', -3302.0], ['b278', -3305.0], ['c278', -3308.0], ['d278', -3311.0], ['a279', -3314.0], ['b279', -3317.0], ['c279', -3320.0], ['d279', -3323.0], ['a280', -3326.0], ['b280', -3329.0], ['c280', -3332.0], ['d280', -3335.0], ['a281', -3338.0], ['b281', -3341.0], ['c281', -3344.0], ['d281', -3347.0], ['a282', -3350.0], ['b282', -3353.0], ['c282', -3356.0], ['d282', -3359.0], ['a283', -3362.0], ['b283', -3365.0], ['c283', -3368.0], ['d283', -3371.0], ['a284', -3374.0], ['b284', -3377.0], ['c284', -3380.0], ['d284', -3383.0], ['a285', -3386.0], ['b285', -3389.0], ['c285', -3392.0], ['d285', -3395.0], ['a286', -3398.0], ['b286', -3401.0], ['c286', -3404.0], ['d286', -3407.0], ['a287', -3410.0], ['b287', -3413.0], ['c287', -3416.0], ['d287', -3419.0], ['a288', -3422.0], ['b288', -3425.0], ['c288', -3428.0], ['d288', -3431.0], ['a289', -3434.0], ['b289', -3437.0], ['c289', -3440.0], ['d289', -3443.0], ['a290', -3446.0], ['b290', -3449.0], ['c290', -3452.0], ['d290', -3455.0], ['a291', -3458.0], ['b291', -3461.0], ['c291', -3464.0], ['d291', -3467.0], ['a292', -3470.0], ['b292', -3473.0], ['c292', -3476.0], ['d292', -3479.0], ['a293', -3482.0], ['b293', -3485.0], ['c293', -3488.0], ['d293', -3491.0], ['a294', -3494.0], ['b294', -3497.0], ['c294', -3500.0], ['d294', -3503.0], ['a295', -3506.0], ['b295', -3509.0], ['c295', -3512.0], ['d295', -3515.0], ['a296', -3518.0], ['b296', -3521.0], ['c296', -3524.0], ['d296', -3527.0], ['a297', -3530.0], ['b297', -3533.0], ['c297', -3536.0], ['d297', -3539.0], ['a298', -3542.0], ['b298', -3545.0], ['c298', -3548.0], ['d298', -3551.0], ['a299', -3554.0], ['b299', -3557.0], ['c299', -3560.0], ['d299', -3563.0], ['a300', -3566.0], ['b300', -3569.0], ['c300', -3572.0], ['d300', -3575.0] }

```

### PowerShellスクリプトの実行アクションを使用した例

リストは「Pythonスクリプトの実行」と同じくテキストに変換してからPowerShellスクリプトに渡します。%PowershellOutput%を「テキストのトリミング」→「テキストを数値に変換」アクションで実行しています。

![](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/680039/85af1537-4b27-36b0-16ef-aa602ba7e27b.png)


PowerShellの場合は次のようにスクリプトを書いています。
![](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/680039/27830dda-55f5-67f8-cde0-995334a6e939.png)


```
$list =@('%JoinedText%')
$index = [Array]::IndexOf($list,'%UserInput%')
echo $index
```

## まとめ

* ループを使用するより早く検索できます。
* スクリプトの実行アクションにリストを渡す場合はテキストに変換する必要があります。
* スクリプトの実行アクションから出力される値も少し扱いにコツがいります。
* PADの標準アクションだけでは難しいことも、スクリプトの実行アクションで解決する場合があります。

## 参考

配列について知りたかったことのすべて
https://docs.microsoft.com/ja-jp/powershell/scripting/learn/deep-dives/everything-about-arrays?view=powershell-7.1

配列内の値を検索する方法
https://bayashita.com/p/entry/show/148