[{"data":1,"prerenderedAt":1194},["ShallowReactive",2],{"blog:2016:developer-tips":3,"blogMore-Development":1180,"comments-developer-tips":1193},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"category":11,"tags":12,"excerpt":15,"body":30,"_type":1171,"_id":1172,"_source":1173,"_file":1174,"_stem":1175,"_extension":1176,"url":1177,"wordCount":1178,"minutes":256,"commentCount":1179},"/blog/2016/developer-tips","2016",false,"en","Random tips for PowerShell, Bash & AWS","Now that I am again freelancing, I find myself solving unusual issues, many of which had no online solutions.","2016-04-28T23:27:23+00:00","Development",[13,14],"AWS","PowerShell",{"type":16,"children":17},"root",[18,25],{"type":19,"tag":20,"props":21,"children":22},"element","p",{},[23],{"type":24,"value":9},"text",{"type":19,"tag":20,"props":26,"children":27},{},[28],{"type":24,"value":29},"Given these no doubt plague other developers, let’s share!",{"type":16,"children":31,"toc":1161},[32,36,40,47,61,71,100,113,118,126,132,161,461,474,479,485,490,506,570,584,739,745,758,764,883,888,1126,1132,1146,1155],{"type":19,"tag":20,"props":33,"children":34},{},[35],{"type":24,"value":9},{"type":19,"tag":20,"props":37,"children":38},{},[39],{"type":24,"value":29},{"type":19,"tag":41,"props":42,"children":44},"h2",{"id":43},"pass-quoted-args-from-batcmd-files-to-powershell",[45],{"type":24,"value":46},"Pass quoted args from BAT/CMD files to PowerShell",{"type":19,"tag":20,"props":48,"children":49},{},[50,52,59],{"type":24,"value":51},"Grabbing args from a batch/command files is easy (use ",{"type":19,"tag":53,"props":54,"children":56},"code",{"className":55},[],[57],{"type":24,"value":58},"%*",{"type":24,"value":60},") but have you ever tried passing them to PowerShell like:",{"type":19,"tag":62,"props":63,"children":65},"pre",{"code":64},"powershell \"Something\" \"%*\"\n",[66],{"type":19,"tag":53,"props":67,"children":69},{"__ignoreMap":68},"",[70],{"type":24,"value":64},{"type":19,"tag":20,"props":72,"children":73},{},[74,76,82,84,90,92,98],{"type":24,"value":75},"Unfortunately, if one of your arguments has quotes around it (a filename containing a space perhaps), it becomes two separate arguments. e.g. ",{"type":19,"tag":53,"props":77,"children":79},{"className":78},[],[80],{"type":24,"value":81},"\"My File.txt\"",{"type":24,"value":83}," now becomes ",{"type":19,"tag":53,"props":85,"children":87},{"className":86},[],[88],{"type":24,"value":89},"My",{"type":24,"value":91}," and ",{"type":19,"tag":53,"props":93,"children":95},{"className":94},[],[96],{"type":24,"value":97},"File.txt",{"type":24,"value":99},".",{"type":19,"tag":20,"props":101,"children":102},{},[103,105,111],{"type":24,"value":104},"PowerShell will only preserve it if you use the -f option (to run a .PS1 file) and that requires a relaxed policy via ",{"type":19,"tag":53,"props":106,"children":108},{"className":107},[],[109],{"type":24,"value":110},"Set-ExecutionPolicy",{"type":24,"value":112}," so is a no-go for many people.",{"type":19,"tag":20,"props":114,"children":115},{},[116],{"type":24,"value":117},"Given you can’t make PowerShell do the right thing with the args the trick here is - to not pass them as args at all!",{"type":19,"tag":62,"props":119,"children":121},{"code":120},"SET MYPSARGS=%*\n...\npowershell -ArgumentList \"$env:MYPSARGS\"\n",[122],{"type":19,"tag":53,"props":123,"children":124},{"__ignoreMap":68},[125],{"type":24,"value":120},{"type":19,"tag":41,"props":127,"children":129},{"id":128},"get-bash-script-path-as-windows-path",[130],{"type":24,"value":131},"Get Bash script path as Windows path",{"type":19,"tag":20,"props":133,"children":134},{},[135,137,143,145,151,153,159],{"type":24,"value":136},"While Cygwin ships with ",{"type":19,"tag":53,"props":138,"children":140},{"className":139},[],[141],{"type":24,"value":142},"cygpath",{"type":24,"value":144}," to convert ",{"type":19,"tag":53,"props":146,"children":148},{"className":147},[],[149],{"type":24,"value":150},"/c/something",{"type":24,"value":152}," to ",{"type":19,"tag":53,"props":154,"children":156},{"className":155},[],[157],{"type":24,"value":158},"c:\\Something",{"type":24,"value":160}," etc. MSYS Bash shells do not have this. You can get it another way there however:",{"type":19,"tag":62,"props":162,"children":166},{"code":163,"language":164,"meta":68,"className":165,"style":68},"#!/bin/sh\npushd \"$(dirname \"$0\")\" &gt; /dev/null\nif command -v \"cygpath\" &gt; /dev/null; then\n  WINPWD=\"\"$(cygpath . -a -w)\"\"\nelse\n  WINPWD=\"\"$(pwd -W)\"\"\nfi\npopd &gt; /dev/null\necho $WINPWD\n","bash","language-bash shiki shiki-themes everforest-light dracula",[167],{"type":19,"tag":53,"props":168,"children":169},{"__ignoreMap":68},[170,182,254,315,369,378,416,425,446],{"type":19,"tag":171,"props":172,"children":175},"span",{"class":173,"line":174},"line",1,[176],{"type":19,"tag":171,"props":177,"children":179},{"style":178},"--shiki-default:#939F91;--shiki-default-font-style:italic;--shiki-dark:#6272A4;--shiki-dark-font-style:inherit",[180],{"type":24,"value":181},"#!/bin/sh\n",{"type":19,"tag":171,"props":183,"children":185},{"class":173,"line":184},2,[186,192,198,204,210,215,221,225,230,234,239,244,249],{"type":19,"tag":171,"props":187,"children":189},{"style":188},"--shiki-default:#5C6A72;--shiki-dark:#F8F8F2",[190],{"type":24,"value":191},"pushd ",{"type":19,"tag":171,"props":193,"children":195},{"style":194},"--shiki-default:#8DA101;--shiki-dark:#E9F284",[196],{"type":24,"value":197},"\"",{"type":19,"tag":171,"props":199,"children":201},{"style":200},"--shiki-default:#5C6A72;--shiki-dark:#F1FA8C",[202],{"type":24,"value":203},"$(",{"type":19,"tag":171,"props":205,"children":207},{"style":206},"--shiki-default:#8DA101;--shiki-dark:#50FA7B",[208],{"type":24,"value":209},"dirname",{"type":19,"tag":171,"props":211,"children":212},{"style":194},[213],{"type":24,"value":214}," \"",{"type":19,"tag":171,"props":216,"children":218},{"style":217},"--shiki-default:#5C6A72;--shiki-default-font-style:inherit;--shiki-dark:#FFB86C;--shiki-dark-font-style:italic",[219],{"type":24,"value":220},"$0",{"type":19,"tag":171,"props":222,"children":223},{"style":194},[224],{"type":24,"value":197},{"type":19,"tag":171,"props":226,"children":227},{"style":200},[228],{"type":24,"value":229},")",{"type":19,"tag":171,"props":231,"children":232},{"style":194},[233],{"type":24,"value":197},{"type":19,"tag":171,"props":235,"children":236},{"style":188},[237],{"type":24,"value":238}," &",{"type":19,"tag":171,"props":240,"children":241},{"style":206},[242],{"type":24,"value":243},"gt",{"type":19,"tag":171,"props":245,"children":246},{"style":188},[247],{"type":24,"value":248},"; ",{"type":19,"tag":171,"props":250,"children":251},{"style":206},[252],{"type":24,"value":253},"/dev/null\n",{"type":19,"tag":171,"props":255,"children":257},{"class":173,"line":256},3,[258,264,270,276,280,285,289,293,297,301,306,310],{"type":19,"tag":171,"props":259,"children":261},{"style":260},"--shiki-default:#F85552;--shiki-dark:#FF79C6",[262],{"type":24,"value":263},"if",{"type":19,"tag":171,"props":265,"children":267},{"style":266},"--shiki-default:#DFA000;--shiki-dark:#8BE9FD",[268],{"type":24,"value":269}," command",{"type":19,"tag":171,"props":271,"children":273},{"style":272},"--shiki-default:#DFA000;--shiki-dark:#BD93F9",[274],{"type":24,"value":275}," -v",{"type":19,"tag":171,"props":277,"children":278},{"style":194},[279],{"type":24,"value":214},{"type":19,"tag":171,"props":281,"children":283},{"style":282},"--shiki-default:#8DA101;--shiki-dark:#F1FA8C",[284],{"type":24,"value":142},{"type":19,"tag":171,"props":286,"children":287},{"style":194},[288],{"type":24,"value":197},{"type":19,"tag":171,"props":290,"children":291},{"style":188},[292],{"type":24,"value":238},{"type":19,"tag":171,"props":294,"children":295},{"style":206},[296],{"type":24,"value":243},{"type":19,"tag":171,"props":298,"children":299},{"style":188},[300],{"type":24,"value":248},{"type":19,"tag":171,"props":302,"children":303},{"style":206},[304],{"type":24,"value":305},"/dev/null",{"type":19,"tag":171,"props":307,"children":308},{"style":188},[309],{"type":24,"value":248},{"type":19,"tag":171,"props":311,"children":312},{"style":260},[313],{"type":24,"value":314},"then\n",{"type":19,"tag":171,"props":316,"children":318},{"class":173,"line":317},4,[319,325,331,336,340,344,350,355,360,364],{"type":19,"tag":171,"props":320,"children":322},{"style":321},"--shiki-default:#5C6A72;--shiki-dark:#BD93F9",[323],{"type":24,"value":324},"  WINPWD",{"type":19,"tag":171,"props":326,"children":328},{"style":327},"--shiki-default:#F57D26;--shiki-dark:#FF79C6",[329],{"type":24,"value":330},"=",{"type":19,"tag":171,"props":332,"children":333},{"style":194},[334],{"type":24,"value":335},"\"\"",{"type":19,"tag":171,"props":337,"children":338},{"style":188},[339],{"type":24,"value":203},{"type":19,"tag":171,"props":341,"children":342},{"style":206},[343],{"type":24,"value":142},{"type":19,"tag":171,"props":345,"children":347},{"style":346},"--shiki-default:#DFA000;--shiki-dark:#F1FA8C",[348],{"type":24,"value":349}," .",{"type":19,"tag":171,"props":351,"children":352},{"style":272},[353],{"type":24,"value":354}," -a",{"type":19,"tag":171,"props":356,"children":357},{"style":272},[358],{"type":24,"value":359}," -w",{"type":19,"tag":171,"props":361,"children":362},{"style":188},[363],{"type":24,"value":229},{"type":19,"tag":171,"props":365,"children":366},{"style":194},[367],{"type":24,"value":368},"\"\"\n",{"type":19,"tag":171,"props":370,"children":372},{"class":173,"line":371},5,[373],{"type":19,"tag":171,"props":374,"children":375},{"style":260},[376],{"type":24,"value":377},"else\n",{"type":19,"tag":171,"props":379,"children":381},{"class":173,"line":380},6,[382,386,390,394,398,403,408,412],{"type":19,"tag":171,"props":383,"children":384},{"style":321},[385],{"type":24,"value":324},{"type":19,"tag":171,"props":387,"children":388},{"style":327},[389],{"type":24,"value":330},{"type":19,"tag":171,"props":391,"children":392},{"style":194},[393],{"type":24,"value":335},{"type":19,"tag":171,"props":395,"children":396},{"style":188},[397],{"type":24,"value":203},{"type":19,"tag":171,"props":399,"children":400},{"style":266},[401],{"type":24,"value":402},"pwd",{"type":19,"tag":171,"props":404,"children":405},{"style":272},[406],{"type":24,"value":407}," -W",{"type":19,"tag":171,"props":409,"children":410},{"style":188},[411],{"type":24,"value":229},{"type":19,"tag":171,"props":413,"children":414},{"style":194},[415],{"type":24,"value":368},{"type":19,"tag":171,"props":417,"children":419},{"class":173,"line":418},7,[420],{"type":19,"tag":171,"props":421,"children":422},{"style":260},[423],{"type":24,"value":424},"fi\n",{"type":19,"tag":171,"props":426,"children":428},{"class":173,"line":427},8,[429,434,438,442],{"type":19,"tag":171,"props":430,"children":431},{"style":188},[432],{"type":24,"value":433},"popd &",{"type":19,"tag":171,"props":435,"children":436},{"style":206},[437],{"type":24,"value":243},{"type":19,"tag":171,"props":439,"children":440},{"style":188},[441],{"type":24,"value":248},{"type":19,"tag":171,"props":443,"children":444},{"style":206},[445],{"type":24,"value":253},{"type":19,"tag":171,"props":447,"children":449},{"class":173,"line":448},9,[450,455],{"type":19,"tag":171,"props":451,"children":452},{"style":266},[453],{"type":24,"value":454},"echo",{"type":19,"tag":171,"props":456,"children":458},{"style":457},"--shiki-default:#DF69BA;--shiki-dark:#BD93F9",[459],{"type":24,"value":460}," $WINPWD\n",{"type":19,"tag":20,"props":462,"children":463},{},[464,466,472],{"type":24,"value":465},"This solution works by switching the working directory to the one the script is in ",{"type":19,"tag":53,"props":467,"children":469},{"className":468},[],[470],{"type":24,"value":471},"\"$(dirname \"$0\")\"",{"type":24,"value":473}," and then capturing the print-working-directory command output using the -W option that grabs it in Windows format. It then pops the working directory to make sure it goes back to where it was.",{"type":19,"tag":20,"props":475,"children":476},{},[477],{"type":24,"value":478},"Note that this uses forward slashes as a directory separator still. Many tools and apps are okay with that but some older ones are not.",{"type":19,"tag":41,"props":480,"children":482},{"id":481},"json-encoding-in-api-gateway-mapping-templates",[483],{"type":24,"value":484},"JSON encoding in API Gateway mapping templates",{"type":19,"tag":20,"props":486,"children":487},{},[488],{"type":24,"value":489},"If you use Amazon’s AWS Lambda you’ll also find yourself touching API Gateway. While most of it is great, the mapping templates are deficient in that they do not encode output by default despite specifying the MIME types.",{"type":19,"tag":20,"props":491,"children":492},{},[493,495,504],{"type":24,"value":494},"All of ",{"type":19,"tag":496,"props":497,"children":501},"a",{"href":498,"rel":499},"https://docs.aws.amazon.com/apigateway/latest/developerguide/models-mappings.html",[500],"nofollow",[502],{"type":24,"value":503},"Amazon’s example templates are exploitable",{"type":24,"value":505}," via JSON injection. Just put a double-quote in a field and start writing any JSON payload.",{"type":19,"tag":20,"props":507,"children":508},{},[509,515,517,523,525,530,532,538,540,545,547,554,556,562,563,569],{"type":19,"tag":510,"props":511,"children":512},"strong",{},[513],{"type":24,"value":514},"Amazon must fix this and encode by default",{"type":24,"value":516}," like other templating systems have done, such as ASP.NET Razor. Until then some recommend the Amazon-provided ",{"type":19,"tag":53,"props":518,"children":520},{"className":519},[],[521],{"type":24,"value":522},"$util.escapeJavaScript()",{"type":24,"value":524}," however while it encodes ",{"type":19,"tag":53,"props":526,"children":528},{"className":527},[],[529],{"type":24,"value":197},{"type":24,"value":531}," as ",{"type":19,"tag":53,"props":533,"children":535},{"className":534},[],[536],{"type":24,"value":537},"\\\"",{"type":24,"value":539}," it also produces ",{"type":19,"tag":510,"props":541,"children":542},{},[543],{"type":24,"value":544},"illegal",{"type":24,"value":546}," ",{"type":19,"tag":496,"props":548,"children":551},{"href":549,"rel":550},"https://www.json.org/",[500],[552],{"type":24,"value":553},"JSON",{"type":24,"value":555}," by encoding ",{"type":19,"tag":53,"props":557,"children":559},{"className":558},[],[560],{"type":24,"value":561},"'",{"type":24,"value":531},{"type":19,"tag":53,"props":564,"children":566},{"className":565},[],[567],{"type":24,"value":568},"\\'",{"type":24,"value":349},{"type":19,"tag":20,"props":571,"children":572},{},[573,575,582],{"type":24,"value":574},"The mapping language is ",{"type":19,"tag":496,"props":576,"children":579},{"href":577,"rel":578},"https://velocity.apache.org/engine/devel/vtl-reference-guide.html",[500],[580],{"type":24,"value":581},"Apache Velocity Template Language (VTL)",{"type":24,"value":583},", and while not extendable, the fine print reveals that it internally uses Java strings and does not sandbox them which let’s us utilize Java’s replace functionality:",{"type":19,"tag":62,"props":585,"children":589},{"code":586,"language":587,"meta":68,"className":588,"style":68},"#set($i = $input.path('$'))\n{\n   \"safeString\": \"$i.unsafeString.replaceAll(\"\\\"\"\", \"\\\\\"\"\")\n}\n","javascript","language-javascript shiki shiki-themes everforest-light dracula",[590],{"type":19,"tag":53,"props":591,"children":592},{"__ignoreMap":68},[593,654,662,731],{"type":19,"tag":171,"props":594,"children":595},{"class":173,"line":174},[596,601,606,611,615,620,625,630,635,640,645,649],{"type":19,"tag":171,"props":597,"children":598},{"style":188},[599],{"type":24,"value":600},"#",{"type":19,"tag":171,"props":602,"children":603},{"style":206},[604],{"type":24,"value":605},"set",{"type":19,"tag":171,"props":607,"children":608},{"style":188},[609],{"type":24,"value":610},"($i ",{"type":19,"tag":171,"props":612,"children":613},{"style":327},[614],{"type":24,"value":330},{"type":19,"tag":171,"props":616,"children":617},{"style":188},[618],{"type":24,"value":619}," $input",{"type":19,"tag":171,"props":621,"children":623},{"style":622},"--shiki-default:#939F91;--shiki-dark:#F8F8F2",[624],{"type":24,"value":99},{"type":19,"tag":171,"props":626,"children":627},{"style":206},[628],{"type":24,"value":629},"path",{"type":19,"tag":171,"props":631,"children":632},{"style":188},[633],{"type":24,"value":634},"(",{"type":19,"tag":171,"props":636,"children":638},{"style":637},"--shiki-default:#DFA000;--shiki-dark:#E9F284",[639],{"type":24,"value":561},{"type":19,"tag":171,"props":641,"children":642},{"style":346},[643],{"type":24,"value":644},"$",{"type":19,"tag":171,"props":646,"children":647},{"style":637},[648],{"type":24,"value":561},{"type":19,"tag":171,"props":650,"children":651},{"style":188},[652],{"type":24,"value":653},"))\n",{"type":19,"tag":171,"props":655,"children":656},{"class":173,"line":184},[657],{"type":19,"tag":171,"props":658,"children":659},{"style":188},[660],{"type":24,"value":661},"{\n",{"type":19,"tag":171,"props":663,"children":664},{"class":173,"line":256},[665,670,675,679,684,688,693,697,702,707,712,716,721,725],{"type":19,"tag":171,"props":666,"children":667},{"style":637},[668],{"type":24,"value":669},"   \"",{"type":19,"tag":171,"props":671,"children":672},{"style":346},[673],{"type":24,"value":674},"safeString",{"type":19,"tag":171,"props":676,"children":677},{"style":637},[678],{"type":24,"value":197},{"type":19,"tag":171,"props":680,"children":681},{"style":188},[682],{"type":24,"value":683},": ",{"type":19,"tag":171,"props":685,"children":686},{"style":637},[687],{"type":24,"value":197},{"type":19,"tag":171,"props":689,"children":690},{"style":346},[691],{"type":24,"value":692},"$i.unsafeString.replaceAll(",{"type":19,"tag":171,"props":694,"children":695},{"style":637},[696],{"type":24,"value":197},{"type":19,"tag":171,"props":698,"children":699},{"style":188},[700],{"type":24,"value":701},"\\",{"type":19,"tag":171,"props":703,"children":704},{"style":637},[705],{"type":24,"value":706},"\"\"\"",{"type":19,"tag":171,"props":708,"children":709},{"style":346},[710],{"type":24,"value":711},", ",{"type":19,"tag":171,"props":713,"children":714},{"style":637},[715],{"type":24,"value":197},{"type":19,"tag":171,"props":717,"children":718},{"style":188},[719],{"type":24,"value":720},"\\\\",{"type":19,"tag":171,"props":722,"children":723},{"style":637},[724],{"type":24,"value":706},{"type":19,"tag":171,"props":726,"children":728},{"style":727},"--shiki-default:#DFA000;--shiki-default-font-style:inherit;--shiki-default-text-decoration:inherit;--shiki-dark:#FF5555;--shiki-dark-font-style:italic;--shiki-dark-text-decoration:underline",[729],{"type":24,"value":730},")\n",{"type":19,"tag":171,"props":732,"children":733},{"class":173,"line":317},[734],{"type":19,"tag":171,"props":735,"children":736},{"style":188},[737],{"type":24,"value":738},"}\n",{"type":19,"tag":41,"props":740,"children":742},{"id":741},"show-active-known-ips-on-the-local-network",[743],{"type":24,"value":744},"Show active known IPs on the local network",{"type":19,"tag":20,"props":746,"children":747},{},[748,750,756],{"type":24,"value":749},"I’m surprised more people don’t know how useful ",{"type":19,"tag":53,"props":751,"children":753},{"className":752},[],[754],{"type":24,"value":755},"arp -a",{"type":24,"value":757}," is, especially if you pipe it into ping…",{"type":19,"tag":759,"props":760,"children":761},"h3",{"id":164},[762],{"type":24,"value":763},"Bash",{"type":19,"tag":62,"props":765,"children":767},{"code":766,"language":164,"meta":68,"className":165,"style":68},"arp -a | grep -o '[0-9]\\{1,3\\}\\.[0-9]\\{1,3\\}\\.[0-9]\\{1,3\\}\\.[0-9]\\{1,3\\}' | xargs -L1 ping -c 1 -t 1 | sed -n -e 's/^.*bytes from //p'\n",[768],{"type":19,"tag":53,"props":769,"children":770},{"__ignoreMap":68},[771],{"type":19,"tag":171,"props":772,"children":773},{"class":173,"line":174},[774,779,783,788,793,798,803,808,812,816,821,826,831,836,841,846,850,854,859,864,869,873,878],{"type":19,"tag":171,"props":775,"children":776},{"style":206},[777],{"type":24,"value":778},"arp",{"type":19,"tag":171,"props":780,"children":781},{"style":272},[782],{"type":24,"value":354},{"type":19,"tag":171,"props":784,"children":785},{"style":327},[786],{"type":24,"value":787}," |",{"type":19,"tag":171,"props":789,"children":790},{"style":206},[791],{"type":24,"value":792}," grep",{"type":19,"tag":171,"props":794,"children":795},{"style":272},[796],{"type":24,"value":797}," -o",{"type":19,"tag":171,"props":799,"children":800},{"style":194},[801],{"type":24,"value":802}," '",{"type":19,"tag":171,"props":804,"children":805},{"style":282},[806],{"type":24,"value":807},"[0-9]\\{1,3\\}\\.[0-9]\\{1,3\\}\\.[0-9]\\{1,3\\}\\.[0-9]\\{1,3\\}",{"type":19,"tag":171,"props":809,"children":810},{"style":194},[811],{"type":24,"value":561},{"type":19,"tag":171,"props":813,"children":814},{"style":327},[815],{"type":24,"value":787},{"type":19,"tag":171,"props":817,"children":818},{"style":206},[819],{"type":24,"value":820}," xargs",{"type":19,"tag":171,"props":822,"children":823},{"style":272},[824],{"type":24,"value":825}," -L1",{"type":19,"tag":171,"props":827,"children":828},{"style":346},[829],{"type":24,"value":830}," ping",{"type":19,"tag":171,"props":832,"children":833},{"style":272},[834],{"type":24,"value":835}," -c",{"type":19,"tag":171,"props":837,"children":838},{"style":457},[839],{"type":24,"value":840}," 1",{"type":19,"tag":171,"props":842,"children":843},{"style":272},[844],{"type":24,"value":845}," -t",{"type":19,"tag":171,"props":847,"children":848},{"style":457},[849],{"type":24,"value":840},{"type":19,"tag":171,"props":851,"children":852},{"style":327},[853],{"type":24,"value":787},{"type":19,"tag":171,"props":855,"children":856},{"style":206},[857],{"type":24,"value":858}," sed",{"type":19,"tag":171,"props":860,"children":861},{"style":272},[862],{"type":24,"value":863}," -n",{"type":19,"tag":171,"props":865,"children":866},{"style":272},[867],{"type":24,"value":868}," -e",{"type":19,"tag":171,"props":870,"children":871},{"style":194},[872],{"type":24,"value":802},{"type":19,"tag":171,"props":874,"children":875},{"style":282},[876],{"type":24,"value":877},"s/^.*bytes from //p",{"type":19,"tag":171,"props":879,"children":880},{"style":194},[881],{"type":24,"value":882},"'\n",{"type":19,"tag":759,"props":884,"children":886},{"id":885},"powershell",[887],{"type":24,"value":14},{"type":19,"tag":62,"props":889,"children":892},{"code":890,"language":885,"meta":68,"className":891,"style":68},"(arp -a) -match \"dynamic\" | Foreach { ping -n 1 -w 1000 ($_ -split \"\\s+\")[1] } | where { $_ -match \"Reply from \" } | % { $_.replace(\"Reply from \",\"\") }\n","language-powershell shiki shiki-themes everforest-light dracula",[893],{"type":19,"tag":53,"props":894,"children":895},{"__ignoreMap":68},[896],{"type":19,"tag":171,"props":897,"children":898},{"class":173,"line":174},[899,904,909,914,919,923,928,932,937,942,947,951,956,961,966,971,976,981,986,991,996,1000,1005,1009,1014,1018,1023,1028,1033,1038,1042,1046,1051,1055,1060,1064,1069,1073,1078,1082,1086,1090,1096,1100,1104,1108,1112,1117,1121],{"type":19,"tag":171,"props":900,"children":901},{"style":188},[902],{"type":24,"value":903},"(arp ",{"type":19,"tag":171,"props":905,"children":906},{"style":327},[907],{"type":24,"value":908},"-",{"type":19,"tag":171,"props":910,"children":911},{"style":188},[912],{"type":24,"value":913},"a) ",{"type":19,"tag":171,"props":915,"children":916},{"style":327},[917],{"type":24,"value":918},"-match",{"type":19,"tag":171,"props":920,"children":921},{"style":194},[922],{"type":24,"value":214},{"type":19,"tag":171,"props":924,"children":925},{"style":282},[926],{"type":24,"value":927},"dynamic",{"type":19,"tag":171,"props":929,"children":930},{"style":194},[931],{"type":24,"value":197},{"type":19,"tag":171,"props":933,"children":935},{"style":934},"--shiki-default:#F57D26;--shiki-dark:#F8F8F2",[936],{"type":24,"value":787},{"type":19,"tag":171,"props":938,"children":939},{"style":260},[940],{"type":24,"value":941}," Foreach",{"type":19,"tag":171,"props":943,"children":944},{"style":188},[945],{"type":24,"value":946}," { ping ",{"type":19,"tag":171,"props":948,"children":949},{"style":327},[950],{"type":24,"value":908},{"type":19,"tag":171,"props":952,"children":953},{"style":188},[954],{"type":24,"value":955},"n ",{"type":19,"tag":171,"props":957,"children":958},{"style":457},[959],{"type":24,"value":960},"1",{"type":19,"tag":171,"props":962,"children":963},{"style":327},[964],{"type":24,"value":965}," -",{"type":19,"tag":171,"props":967,"children":968},{"style":188},[969],{"type":24,"value":970},"w ",{"type":19,"tag":171,"props":972,"children":973},{"style":457},[974],{"type":24,"value":975},"1000",{"type":19,"tag":171,"props":977,"children":978},{"style":188},[979],{"type":24,"value":980}," (",{"type":19,"tag":171,"props":982,"children":984},{"style":983},"--shiki-default:#939F91;--shiki-dark:#BD93F9",[985],{"type":24,"value":644},{"type":19,"tag":171,"props":987,"children":988},{"style":321},[989],{"type":24,"value":990},"_",{"type":19,"tag":171,"props":992,"children":993},{"style":327},[994],{"type":24,"value":995}," -split",{"type":19,"tag":171,"props":997,"children":998},{"style":194},[999],{"type":24,"value":214},{"type":19,"tag":171,"props":1001,"children":1002},{"style":282},[1003],{"type":24,"value":1004},"\\s+",{"type":19,"tag":171,"props":1006,"children":1007},{"style":194},[1008],{"type":24,"value":197},{"type":19,"tag":171,"props":1010,"children":1011},{"style":188},[1012],{"type":24,"value":1013},")[",{"type":19,"tag":171,"props":1015,"children":1016},{"style":457},[1017],{"type":24,"value":960},{"type":19,"tag":171,"props":1019,"children":1020},{"style":188},[1021],{"type":24,"value":1022},"] } ",{"type":19,"tag":171,"props":1024,"children":1025},{"style":934},[1026],{"type":24,"value":1027},"|",{"type":19,"tag":171,"props":1029,"children":1030},{"style":260},[1031],{"type":24,"value":1032}," where",{"type":19,"tag":171,"props":1034,"children":1035},{"style":188},[1036],{"type":24,"value":1037}," { ",{"type":19,"tag":171,"props":1039,"children":1040},{"style":983},[1041],{"type":24,"value":644},{"type":19,"tag":171,"props":1043,"children":1044},{"style":321},[1045],{"type":24,"value":990},{"type":19,"tag":171,"props":1047,"children":1048},{"style":327},[1049],{"type":24,"value":1050}," -match",{"type":19,"tag":171,"props":1052,"children":1053},{"style":194},[1054],{"type":24,"value":214},{"type":19,"tag":171,"props":1056,"children":1057},{"style":282},[1058],{"type":24,"value":1059},"Reply from ",{"type":19,"tag":171,"props":1061,"children":1062},{"style":194},[1063],{"type":24,"value":197},{"type":19,"tag":171,"props":1065,"children":1066},{"style":188},[1067],{"type":24,"value":1068}," } ",{"type":19,"tag":171,"props":1070,"children":1071},{"style":934},[1072],{"type":24,"value":1027},{"type":19,"tag":171,"props":1074,"children":1075},{"style":260},[1076],{"type":24,"value":1077}," %",{"type":19,"tag":171,"props":1079,"children":1080},{"style":188},[1081],{"type":24,"value":1037},{"type":19,"tag":171,"props":1083,"children":1084},{"style":983},[1085],{"type":24,"value":644},{"type":19,"tag":171,"props":1087,"children":1088},{"style":321},[1089],{"type":24,"value":990},{"type":19,"tag":171,"props":1091,"children":1093},{"style":1092},"--shiki-default:#35A77C;--shiki-dark:#F8F8F2",[1094],{"type":24,"value":1095},".replace",{"type":19,"tag":171,"props":1097,"children":1098},{"style":188},[1099],{"type":24,"value":634},{"type":19,"tag":171,"props":1101,"children":1102},{"style":194},[1103],{"type":24,"value":197},{"type":19,"tag":171,"props":1105,"children":1106},{"style":282},[1107],{"type":24,"value":1059},{"type":19,"tag":171,"props":1109,"children":1110},{"style":194},[1111],{"type":24,"value":197},{"type":19,"tag":171,"props":1113,"children":1114},{"style":934},[1115],{"type":24,"value":1116},",",{"type":19,"tag":171,"props":1118,"children":1119},{"style":194},[1120],{"type":24,"value":335},{"type":19,"tag":171,"props":1122,"children":1123},{"style":188},[1124],{"type":24,"value":1125},") }\n",{"type":19,"tag":41,"props":1127,"children":1129},{"id":1128},"wrapping-up",[1130],{"type":24,"value":1131},"Wrapping up",{"type":19,"tag":20,"props":1133,"children":1134},{},[1135,1137,1144],{"type":24,"value":1136},"I just want to mention that if you are doing anything on a command-line, be it Bash, OS X, PowerShell or Command/Batch then ",{"type":19,"tag":496,"props":1138,"children":1141},{"href":1139,"rel":1140},"https://ss64.com",[500],[1142],{"type":24,"value":1143},"SS64",{"type":24,"value":1145}," is a site worth visiting as they have great docs on many of these things!",{"type":19,"tag":20,"props":1147,"children":1148},{},[1149],{"type":19,"tag":1150,"props":1151,"children":1152},"em",{},[1153],{"type":24,"value":1154},"[)amien",{"type":19,"tag":1156,"props":1157,"children":1158},"style",{},[1159],{"type":24,"value":1160},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":68,"searchDepth":184,"depth":184,"links":1162},[1163,1164,1165,1166,1170],{"id":43,"depth":184,"text":46},{"id":128,"depth":184,"text":131},{"id":481,"depth":184,"text":484},{"id":741,"depth":184,"text":744,"children":1167},[1168,1169],{"id":164,"depth":256,"text":763},{"id":885,"depth":256,"text":14},{"id":1128,"depth":184,"text":1131},"markdown","content:blog:2016:developer-tips.md","content","blog/2016/developer-tips.md","blog/2016/developer-tips","md","/blog/2016/developer-tips/",673,0,[1181,1185,1189],{"title":1182,"date":1183,"url":1184},"HTML5 Video Cheatsheet: Optimizing videos for the web","2025-12-05T00:00:00Z","/blog/2025/html5-video-cheatsheet/",{"title":1186,"date":1187,"url":1188},"Transactions in the MongoDB EF Core Provider","2025-10-25","/blog/2025/mongodb-explicit-transactions/",{"title":1190,"date":1191,"url":1192},"Queryable Encryption with the MongoDB EF Core Provider","2025-09-22","/blog/2025/mongodb-queryable-encryption/",[],1779224704930]