Get a List of All Yammer Group Administrators Part 2

%3CLINGO-SUB%20id%3D%22lingo-sub-13380%22%20slang%3D%22en-US%22%3EGet%20a%20List%20of%20All%20Yammer%20Group%20Administrators%20Part%202%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-13380%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20is%20the%20second%20part%20of%20the%20post.%20%26nbsp%3BGo%20here%20to%20get%20the%20first%20part%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FYammer%2FGet-a-List-of-All-Yammer-Group-Administrators-Part-1%2Fm-p%2F13378%23M636%22%20target%3D%22_self%22%3Ehttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FYammer%2FGet-a-List-of-All-Yammer-Group-Administrators-Part-1%2Fm-p%2F13378%23M636%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%40echo%20off%0AREM%20This%20batch%20file%20will%20take%20items%20in%20Groups.csv%20in%20the%20current%20directory%20and%20create%20a%20workbook%0AREM%20containing%20the%20first%2050%20users%20of%20each%20group%2C%20including%20all%20group%20admins%2C%20as%20well%20as%20other%20group%20data.%0AREM%20%20Requires%20write%20permission%20to%20the%20current%20directory.%0AREM%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0AREM%20%C2%A9%20Tom%20Kretzmer%20May%202016.%0AREM%20Version%201.0%20(First%20complete)%0AREM%20Flow%20-%20Build%20scripts%2C%20call%20in.vbs%20to%20get%20token%2C%20run%20GetAdmins.ps1%20to%20get%20raw%20xml%20per%20group.%20%20Per%20each%20file%20use%20SetFormattingEach.vbs%20to%20reformat%20from%20Yammer-based%20XML%20to%20something%20we%20can%20use.%20%20%0AREM%20Use%20ConCatBuild.vbs%20and%20replacetext.vbs%20to%20build%20concatenating%20batch%20file%2C%20then%20run%20that%20file.%20%20Use%20NoArrow.vbs%20and%20SetFormattingLast.vbs%20to%20make%20the%20full%20file%20legible%20to%20XML%20reader.%0AREM%20Just%20to%20be%20nice%2C%20run%20NormalizeText.ps1%20at%20the%20end%20so%20that%20it%20looks%20pretty%20in%20Notepad.%20%20Then%2C%20open%20in%20Excel%20(if%20installed%20in%20Office15%20directory)%0Aset%20CurrentDirectory%3D%25cd%25%0Aif%20not%20exist%20%25CurrentDirectory%25%5CGroups.csv%20echo%20This%20script%20will%20not%20run%20without%20Groups.csv%20in%20the%20same%20directory%20as%20this%20file.%0Aif%20not%20exist%20%25CurrentDirectory%25%5CGroups.csv%20pause%0Aif%20not%20exist%20%25CurrentDirectory%25%5CGroups.csv%20goto%20End%0Aecho%20Building%20environment...%0Aif%20not%20exist%20%25CurrentDirectory%25%5CGetGroupAdmins%20md%20%25CurrentDirectory%25%5CGetGroupAdmins%0Aif%20not%20exist%20%25CurrentDirectory%25%5CGetGroupAdmins%5COutput%20md%20%25CurrentDirectory%25%5CGetGroupAdmins%5COutput%0Acopy%20%2Fy%20%25CurrentDirectory%25%5CGroups.csv%20%25CurrentDirectory%25%5CGetGroupAdmins%5C%0Acd%20%25CurrentDirectory%25%5CGetGroupAdmins%0AREM%0Acall%20%3ABuildScripts%0AREM%0Acscript%20%2F%2Fnologo%20%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Apowershell%20.%5CGetAdmins.ps1%0Adir%20%25CurrentDirectory%25%5CGetGroupAdmins%5COutput%5C.%20%2Fb%20%26gt%3B%20%25CurrentDirectory%25%5CGetGroupAdmins%5CFiles.txt%0AFOR%20%2FF%20%22delims%3D~%22%20%25%25i%20IN%20(%25CurrentDirectory%25%5CGetGroupAdmins%5CFiles.txt)%20DO%20call%20%3AFormatXML%20%25%25i%0Acopy%20%2Fy%20%20%25CurrentDirectory%25%5CGetGroupAdmins%5CFiles.txt%20%20%25CurrentDirectory%25%5CGetGroupAdmins%5COutputs.bat%0Acscript%20%2F%2Fnologo%20%25CurrentDirectory%25%5CGetGroupAdmins%5CConCatBuild.vbs%0AREM%20This%20bit%20is%20buggy%20but%20it%20works%0Acscript%20%2F%2Fnologo%20%25CurrentDirectory%25%5CGetGroupAdmins%5CConCatBuild.vbs%0Acscript%20%2F%2Fnologo%20%25CurrentDirectory%25%5CGetGroupAdmins%5Creplacetext.vbs%20%25CurrentDirectory%25%5CGetGroupAdmins%5COutputs.bat%20%22copy%20copy%22%20%22copy%22%0AREM%20End%20buggy%20bit%0Acd%20%25CurrentDirectory%25%5CGetGroupAdmins%5COutput%0Acall%20..%5COutputs.bat%0Acd%20%25CurrentDirectory%25%5CGetGroupAdmins%0Acscript%20%2F%2Fnologo%20%25CurrentDirectory%25%5CGetGroupAdmins%5CNoArrow.vbs%20%25CurrentDirectory%25%5CGetGroupAdmins%5COutput%5CAllGroups.xml%0Acscript%20%2F%2Fnologo%20%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingLast.vbs%20%25CurrentDirectory%25%5CGetGroupAdmins%5COutput%5CAllGroups.xml%0Apowershell%20.%5CNormalizeText.ps1%0Aecho%20We'll%20try%20to%20open%20the%20file%2C%20but%20this%20won't%20work%20if%20Excel%20is%20loaded%20to%20a%20different%20directory.%0A%22C%3A%5CProgram%20Files%20(x86)%5CMicrosoft%20Office%5COffice15%5CEXCEL.EXE%22%20%25CurrentDirectory%25%5CGetGroupAdmins%5COutput%5CAllGroups.xml%0Apause%0AREM%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0AREM%20Don't%20run%20subroutines%20at%20end%20of%20batch%0AREM%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0Agoto%20End%0AREM%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0AREM%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A%3ABuildScripts%0Aecho.%0Aecho.%0Aecho%20Building%20Main%20PowerShell%20Script...%0Aecho.%0Aecho%20%20%24token%20%3D%20%22~~Token~~%22%20%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%0Aecho%20%20%24Headers%20%3D%20%40%7B%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%0Aecho%20%20%22Accept%22%20%3D%20%22*%2F*%22%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%0Aecho%20%20%22Authorization%22%20%3D%20%22Bearer%20%22%2B%24token%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%0Aecho%20%20%22accept-encoding%22%20%3D%20%22gzip%22%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%0Aecho%20%20%22content-type%22%3D%22application%2Fjson%22%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%0Aecho%20%20%22content-length%22%20%3D%20%222%22%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%0Aecho%20%20%7D%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%0Aecho%20%23import%20Group%20ID's%20that%20need%20evaluated.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%0Aecho%20%20%24groups%20%3D%20import-csv%20%25CurrentDirectory%25%5CGetGroupAdmins%5CGroups.csv%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%0Aecho%20%20%24groups%20%3D%20%24groups.id%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%0Aecho%20%23loop%20through%20all%20Group%20ID's%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%0Aecho%20%20foreach%20(%24group%20in%20%24groups)%7B%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%0Aecho%20%20%24uri%20%3D%20%22https%3A%2F%2Fwww.yammer.com%2Fapi%2Fv1%2Fgroups%2F%24group%2Fmembers.xml%22%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%0Aecho%20%20%24ExportedFile%20%3D%20%22%25CurrentDirectory%25%5CGetGroupAdmins%5COutput%5C%24group.xml%22%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%0Aecho%20Write-Host%20%24uri%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%0Aecho%20(Invoke-WebRequest%20-Uri%20%24uri%20-Method%20Get%20-Headers%20%24Headers%20-passthru%20-outfile%20%24ExportedFile).content%20%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%0Aecho%20%20%7D%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%0Aecho%20Done.%0Aecho.%0Aecho.%0Aecho%20Building%20Set%20format%20per%20file%20script...%0Aecho%20Const%20ForReading%20%3D%201%20%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingEach.vbs%0Aecho%20Const%20ForWriting%20%3D%202%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingEach.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingEach.vbs%0Aecho%20strFileName%20%3D%20Wscript.Arguments(0)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingEach.vbs%0Aecho%20strXMLHeader%20%3D%20%22%26lt%3B%3Fxml%20version%3D%22%20%5E%26amp%3B%20Chr(34)%20%5E%26amp%3B%20%221.0%22%20%5E%26amp%3B%20Chr%20(34)%20%5E%26amp%3B%20%22%20encoding%3D%22%20%5E%26amp%3B%20Chr(34)%20%5E%26amp%3B%20%22UTF-8%22%20%5E%26amp%3B%20Chr(34)%20%5E%26amp%3B%20%22%3F%26gt%3B%22%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingEach.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingEach.vbs%0Aecho%20strHeaderText%20%3D%20%22%26lt%3BGroupAdminsGroupTag%26gt%3B%22%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingEach.vbs%0Aecho%20strHash%20%3D%20%22%26lt%3Bhash%26gt%3B%22%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingEach.vbs%0Aecho%20strBlankText%20%3D%20%22%22%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingEach.vbs%0Aecho%20strXMLFooter%20%3D%20%22%26lt%3B%2Fhash%26gt%3B%22%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingEach.vbs%0Aecho%20strFooterText%20%3D%20%22%26lt%3B%2FGroupAdminsGroupTag%26gt%3B%22%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingEach.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingEach.vbs%0Aecho%20Set%20objFSO%20%3D%20CreateObject(%22Scripting.FileSystemObject%22)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingEach.vbs%0Aecho%20Set%20objFile%20%3D%20objFSO.OpenTextFile(strFileName%2C%20ForReading)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingEach.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingEach.vbs%0Aecho%20strText%20%3D%20objFile.ReadAll%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingEach.vbs%0Aecho%20objFile.Close%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingEach.vbs%0Aecho%20strHeaderText%20%3D%20Replace(strText%2CstrXMLHeader%2C%20strHeaderText)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingEach.vbs%0Aecho%20strNoHash%20%3D%20Replace(strHeaderText%2CstrHash%2C%20strBlankText)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingEach.vbs%0Aecho%20strNewText%20%3D%20Replace(strNoHash%2CstrXMLFooter%2C%20strFooterText)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingEach.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingEach.vbs%0Aecho%20Set%20objFile%20%3D%20objFSO.OpenTextFile(strFileName%2C%20ForWriting)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingEach.vbs%0Aecho%20objFile.WriteLine%20strNewText%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingEach.vbs%0Aecho%20objFile.Close%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingEach.vbs%0Aecho%20Done%0Aecho.%0Aecho.%0Aecho%20Building%20Input%20script...%0Aecho.%0Aecho%20Dim%20Input%20%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Aecho%20Const%20ForReading%20%3D%201%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Aecho%20Const%20ForWriting%20%3D%202%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Aecho%20strFileName%20%3D%20%22%25CurrentDirectory%25%5CGetGroupAdmins%5CGetAdmins.ps1%22%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Aecho%20strOldText%20%3D%20%22~~Token~~%22%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Aecho%20Set%20objFSO%20%3D%20CreateObject(%22Scripting.FileSystemObject%22)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Aecho%20Set%20objFile%20%3D%20objFSO.OpenTextFile(strFileName%2C%20ForReading)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Aecho%20strInput%20%3D%20InputBox(%22Enter%20Your%20Token%20Here%22%2C%20%22Token%22)%20%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Aecho%20MsgBox%20(%22You%20entered%3A%20%22%20%5E%26amp%3B%20strInput)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Aecho%20strNewText%20%3D%20strInput%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Aecho%20strText%20%3D%20objFile.ReadAll%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Aecho%20objFile.Close%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Aecho%20strNewText%20%3D%20Replace(strText%2C%20strOldText%2C%20strNewText)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Aecho%20Set%20objFile%20%3D%20objFSO.OpenTextFile(strFileName%2C%20ForWriting)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Aecho%20objFile.WriteLine%20strNewText%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Aecho%20objFile.Close%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Cin.vbs%0Aecho%20Done%0Aecho.%0Aecho.%0Aecho%20Building%20Text%20Replacement%20script...%0Aecho.%0Aecho%20Const%20ForReading%20%3D%201%20%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Creplacetext.vbs%0Aecho%20Const%20ForWriting%20%3D%202%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Creplacetext.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Creplacetext.vbs%0Aecho%20strFileName%20%3D%20Wscript.Arguments(0)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Creplacetext.vbs%0Aecho%20strOldText%20%3D%20Wscript.Arguments(1)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Creplacetext.vbs%0Aecho%20strNewText%20%3D%20Wscript.Arguments(2)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Creplacetext.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Creplacetext.vbs%0Aecho%20Set%20objFSO%20%3D%20CreateObject(%22Scripting.FileSystemObject%22)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Creplacetext.vbs%0Aecho%20Set%20objFile%20%3D%20objFSO.OpenTextFile(strFileName%2C%20ForReading)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Creplacetext.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Creplacetext.vbs%0Aecho%20strText%20%3D%20objFile.ReadAll%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Creplacetext.vbs%0Aecho%20objFile.Close%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Creplacetext.vbs%0Aecho%20strNewText%20%3D%20Replace(strText%2C%20strOldText%2C%20strNewText)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Creplacetext.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Creplacetext.vbs%0Aecho%20Set%20objFile%20%3D%20objFSO.OpenTextFile(strFileName%2C%20ForWriting)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Creplacetext.vbs%0Aecho%20objFile.WriteLine%20strNewText%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Creplacetext.vbs%0Aecho%20objFile.Close%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5Creplacetext.vbs%0Aecho%20Done.%0Aecho.%0Aecho.%0Aecho%20Building%20Concatonation%20script...%0Aecho.%0Aecho%20Const%20ForReading%20%3D%201%20%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CConCatBuild.vbs%0Aecho%20Const%20ForWriting%20%3D%202%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CConCatBuild.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CConCatBuild.vbs%0Aecho%20strFileName%20%3D%20%22%25CurrentDirectory%25%5CGetGroupAdmins%5COutputs.bat%22%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CConCatBuild.vbs%0Aecho%20strOldText%20%3D%20%22.xml%22%20%5E%26amp%3B%20vbcrlf%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CConCatBuild.vbs%0Aecho%20strNewText%20%3D%20%22.xml%20%2B%20%22%20%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CConCatBuild.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CConCatBuild.vbs%0Aecho%20Set%20objFSO%20%3D%20CreateObject(%22Scripting.FileSystemObject%22)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CConCatBuild.vbs%0Aecho%20Set%20objFile%20%3D%20objFSO.OpenTextFile(strFileName%2C%20ForReading)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CConCatBuild.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CConCatBuild.vbs%0Aecho%20strText%20%3D%20objFile.ReadAll%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CConCatBuild.vbs%0Aecho%20objFile.Close%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CConCatBuild.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CConCatBuild.vbs%0Aecho%20strText%20%3D%20%22copy%20%22%20%5E%26amp%3B%20strText%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CConCatBuild.vbs%0Aecho%20strFirstPassText%20%3D%20Replace(strText%2C%20strOldText%2C%20strNewText)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CConCatBuild.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CConCatBuild.vbs%0Aecho%20strSecondOldText%20%3D%20%22%2B%20%22%20%5E%26amp%3B%20vbcrlf%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CConCatBuild.vbs%0Aecho%20strSecondNewText%20%3D%20%22AllGroups.xml%22%20%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CConCatBuild.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CConCatBuild.vbs%0Aecho%20strSecondPassText%20%3D%20Replace(strFirstPassText%2C%20strSecondOldText%2C%20strSecondNewText)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CConCatBuild.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CConCatBuild.vbs%0Aecho%20Set%20objFile%20%3D%20objFSO.OpenTextFile(strFileName%2C%20ForWriting)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CConCatBuild.vbs%0Aecho%20objFile.WriteLine%20strSecondPassText%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CConCatBuild.vbs%0Aecho%20objFile.Close%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CConCatBuild.vbs%0Aecho%20Done.%0Aecho.%0Aecho.%0Aecho%20Building%20Arrow%20deletion%20script...%0Aecho.%0Aecho%20Const%20ForReading%20%3D%201%20%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CNoArrow.vbs%0Aecho%20Const%20ForWriting%20%3D%202%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CNoArrow.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CNoArrow.vbs%0Aecho%20strFileName%20%3D%20Wscript.Arguments(0)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CNoArrow.vbs%0Aecho%20strBlankText%20%3D%20%22%22%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CNoArrow.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CNoArrow.vbs%0Aecho%20Set%20objFSO%20%3D%20CreateObject(%22Scripting.FileSystemObject%22)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CNoArrow.vbs%0Aecho%20Set%20objFile%20%3D%20objFSO.OpenTextFile(strFileName%2C%20ForReading)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CNoArrow.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CNoArrow.vbs%0Aecho%20strText%20%3D%20objFile.ReadAll%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CNoArrow.vbs%0Aecho%20objFile.Close%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CNoArrow.vbs%0Aecho%20strNewText%20%3D%20Replace(strText%2C%20Chr(26)%2C%20strBlankText)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CNoArrow.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CNoArrow.vbs%0Aecho%20Set%20objFile%20%3D%20objFSO.OpenTextFile(strFileName%2C%20ForWriting)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CNoArrow.vbs%0Aecho%20objFile.WriteLine%20strNewText%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CNoArrow.vbs%0Aecho%20objFile.Close%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CNoArrow.vbs%0Aecho%20Done.%0Aecho.%0Aecho.%0Aecho%20Building%20Overall%20final%20file%20formatting%0Aecho%20Const%20ForReading%20%3D%201%20%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingLast.vbs%0Aecho%20Const%20ForWriting%20%3D%202%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingLast.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingLast.vbs%0Aecho%20strFileName%20%3D%20Wscript.Arguments(0)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingLast.vbs%0Aecho%20strXMLHeader%20%3D%20%22%26lt%3B%3Fxml%20version%3D%22%20%5E%26amp%3B%20Chr(34)%20%5E%26amp%3B%20%221.0%22%20%5E%26amp%3B%20Chr%20(34)%20%5E%26amp%3B%20%22%20encoding%3D%22%20%5E%26amp%3B%20Chr(34)%20%5E%26amp%3B%20%22UTF-8%22%20%5E%26amp%3B%20Chr(34)%20%5E%26amp%3B%20%22%3F%26gt%3B%22%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingLast.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingLast.vbs%0Aecho%20strHash%20%3D%20%22%26lt%3Bhash%26gt%3B%22%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingLast.vbs%0Aecho%20strXMLFooter%20%3D%20%22%26lt%3B%2Fhash%26gt%3B%22%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingLast.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingLast.vbs%0Aecho%20Set%20objFSO%20%3D%20CreateObject(%22Scripting.FileSystemObject%22)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingLast.vbs%0Aecho%20Set%20objFile%20%3D%20objFSO.OpenTextFile(strFileName%2C%20ForReading)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingLast.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingLast.vbs%0Aecho%20strText%20%3D%20objFile.ReadAll%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingLast.vbs%0Aecho%20objFile.Close%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingLast.vbs%0Aecho%20strNewText%20%3D%20strXMLHeader%20%5E%26amp%3B%20strHash%20%5E%26amp%3B%20strText%20%5E%26amp%3B%20strXMLFooter%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingLast.vbs%0Aecho.%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingLast.vbs%0Aecho%20Set%20objFile%20%3D%20objFSO.OpenTextFile(strFileName%2C%20ForWriting)%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingLast.vbs%0Aecho%20objFile.WriteLine%20strNewText%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingLast.vbs%0Aecho%20objFile.Close%20%26gt%3B%26gt%3B%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingLast.vbs%0Aecho%20Done.%0Aecho.%0Aecho.%0Aecho%20Building%20the%20Last%20make%20pretty%20PowerShell%20script.%0Aecho%20(Get-Content%20%22%25CurrentDirectory%25%5CGetGroupAdmins%5COutput%5CAllGroups.xml%22)%20%5E%7C%20%26gt%3B%20%25CurrentDirectory%25%5CGetGroupAdmins%5CNormalizeText.ps1%0Aecho%20Set-Content%20%22%25CurrentDirectory%25%5CGetGroupAdmins%5COutput%5CAllGroups.xml%22%20%26gt%3B%26gt%3B%20%25CurrentDirectory%25%5CGetGroupAdmins%5CNormalizeText.ps1%0Aecho%20Done.%0Aecho.%0Aecho.%0Agoto%20End%0AREM%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0AREM%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A%3AFormatXML%0Aset%20FileName%3D%251%0AREM%20copy%20%2Fy%20%25CurrentDirectory%25%5CGetGroupAdmins%5COutput%5C%25FileName%25%20%25CurrentDirectory%25%5CGetGroupAdmins%5COutput%5CFormatted%25FileName%25%0Acscript%20%2F%2Fnologo%20%25CurrentDirectory%25%5CGetGroupAdmins%5CSetFormattingEach.vbs%20%25CurrentDirectory%25%5CGetGroupAdmins%5COutput%5C%25FileName%25%0Aset%20FileName%3D%0Agoto%20End%0AREM%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0AREM%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A%3AEnd%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Regular Contributor

This is the second part of the post.  Go here to get the first part:

 

https://techcommunity.microsoft.com/t5/Yammer/Get-a-List-of-All-Yammer-Group-Administrators-Part-1/m...

 

@echo off
REM This batch file will take items in Groups.csv in the current directory and create a workbook
REM containing the first 50 users of each group, including all group admins, as well as other group data.
REM  Requires write permission to the current directory.
REM ==================================
REM © Tom Kretzmer May 2016.
REM Version 1.0 (First complete)
REM Flow - Build scripts, call in.vbs to get token, run GetAdmins.ps1 to get raw xml per group.  Per each file use SetFormattingEach.vbs to reformat from Yammer-based XML to something we can use.  
REM Use ConCatBuild.vbs and replacetext.vbs to build concatenating batch file, then run that file.  Use NoArrow.vbs and SetFormattingLast.vbs to make the full file legible to XML reader.
REM Just to be nice, run NormalizeText.ps1 at the end so that it looks pretty in Notepad.  Then, open in Excel (if installed in Office15 directory)
set CurrentDirectory=%cd%
if not exist %CurrentDirectory%\Groups.csv echo This script will not run without Groups.csv in the same directory as this file.
if not exist %CurrentDirectory%\Groups.csv pause
if not exist %CurrentDirectory%\Groups.csv goto End
echo Building environment...
if not exist %CurrentDirectory%\GetGroupAdmins md %CurrentDirectory%\GetGroupAdmins
if not exist %CurrentDirectory%\GetGroupAdmins\Output md %CurrentDirectory%\GetGroupAdmins\Output
copy /y %CurrentDirectory%\Groups.csv %CurrentDirectory%\GetGroupAdmins\
cd %CurrentDirectory%\GetGroupAdmins
REM
call :BuildScripts
REM
cscript //nologo %CurrentDirectory%\GetGroupAdmins\in.vbs
powershell .\GetAdmins.ps1
dir %CurrentDirectory%\GetGroupAdmins\Output\. /b > %CurrentDirectory%\GetGroupAdmins\Files.txt
FOR /F "delims=~" %%i IN (%CurrentDirectory%\GetGroupAdmins\Files.txt) DO call :FormatXML %%i
copy /y  %CurrentDirectory%\GetGroupAdmins\Files.txt  %CurrentDirectory%\GetGroupAdmins\Outputs.bat
cscript //nologo %CurrentDirectory%\GetGroupAdmins\ConCatBuild.vbs
REM This bit is buggy but it works
cscript //nologo %CurrentDirectory%\GetGroupAdmins\ConCatBuild.vbs
cscript //nologo %CurrentDirectory%\GetGroupAdmins\replacetext.vbs %CurrentDirectory%\GetGroupAdmins\Outputs.bat "copy copy" "copy"
REM End buggy bit
cd %CurrentDirectory%\GetGroupAdmins\Output
call ..\Outputs.bat
cd %CurrentDirectory%\GetGroupAdmins
cscript //nologo %CurrentDirectory%\GetGroupAdmins\NoArrow.vbs %CurrentDirectory%\GetGroupAdmins\Output\AllGroups.xml
cscript //nologo %CurrentDirectory%\GetGroupAdmins\SetFormattingLast.vbs %CurrentDirectory%\GetGroupAdmins\Output\AllGroups.xml
powershell .\NormalizeText.ps1
echo We'll try to open the file, but this won't work if Excel is loaded to a different directory.
"C:\Program Files (x86)\Microsoft Office\Office15\EXCEL.EXE" %CurrentDirectory%\GetGroupAdmins\Output\AllGroups.xml
pause
REM ================
REM Don't run subroutines at end of batch
REM ================
goto End
REM =====================================
REM =====================================
:BuildScripts
echo.
echo.
echo Building Main PowerShell Script...
echo.
echo  $token = "~~Token~~" >%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1
echo. >>%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1
echo  $Headers = @{ >>%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1
echo  "Accept" = "*/*" >>%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1
echo  "Authorization" = "Bearer "+$token >>%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1
echo  "accept-encoding" = "gzip" >>%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1
echo  "content-type"="application/json" >>%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1
echo  "content-length" = "2" >>%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1
echo  } >>%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1
echo. >>%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1
echo #import Group ID's that need evaluated. >>%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1
echo  $groups = import-csv %CurrentDirectory%\GetGroupAdmins\Groups.csv >>%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1
echo  $groups = $groups.id >>%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1
echo. >>%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1
echo #loop through all Group ID's >>%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1
echo  foreach ($group in $groups){ >>%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1
echo. >>%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1
echo  $uri = "https://www.yammer.com/api/v1/groups/$group/members.xml" >>%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1
echo. >>%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1
echo  $ExportedFile = "%CurrentDirectory%\GetGroupAdmins\Output\$group.xml" >>%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1
echo. >>%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1
echo Write-Host $uri >>%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1
echo. >>%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1
echo (Invoke-WebRequest -Uri $uri -Method Get -Headers $Headers -passthru -outfile $ExportedFile).content  >>%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1
echo. >>%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1
echo  } >>%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1
echo Done.
echo.
echo.
echo Building Set format per file script...
echo Const ForReading = 1 >%CurrentDirectory%\GetGroupAdmins\SetFormattingEach.vbs
echo Const ForWriting = 2 >>%CurrentDirectory%\GetGroupAdmins\SetFormattingEach.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\SetFormattingEach.vbs
echo strFileName = Wscript.Arguments(0) >>%CurrentDirectory%\GetGroupAdmins\SetFormattingEach.vbs
echo strXMLHeader = "<?xml version=" ^& Chr(34) ^& "1.0" ^& Chr (34) ^& " encoding=" ^& Chr(34) ^& "UTF-8" ^& Chr(34) ^& "?>" >>%CurrentDirectory%\GetGroupAdmins\SetFormattingEach.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\SetFormattingEach.vbs
echo strHeaderText = "<GroupAdminsGroupTag>" >>%CurrentDirectory%\GetGroupAdmins\SetFormattingEach.vbs
echo strHash = "<hash>" >>%CurrentDirectory%\GetGroupAdmins\SetFormattingEach.vbs
echo strBlankText = "" >>%CurrentDirectory%\GetGroupAdmins\SetFormattingEach.vbs
echo strXMLFooter = "</hash>" >>%CurrentDirectory%\GetGroupAdmins\SetFormattingEach.vbs
echo strFooterText = "</GroupAdminsGroupTag>" >>%CurrentDirectory%\GetGroupAdmins\SetFormattingEach.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\SetFormattingEach.vbs
echo Set objFSO = CreateObject("Scripting.FileSystemObject") >>%CurrentDirectory%\GetGroupAdmins\SetFormattingEach.vbs
echo Set objFile = objFSO.OpenTextFile(strFileName, ForReading) >>%CurrentDirectory%\GetGroupAdmins\SetFormattingEach.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\SetFormattingEach.vbs
echo strText = objFile.ReadAll >>%CurrentDirectory%\GetGroupAdmins\SetFormattingEach.vbs
echo objFile.Close >>%CurrentDirectory%\GetGroupAdmins\SetFormattingEach.vbs
echo strHeaderText = Replace(strText,strXMLHeader, strHeaderText) >>%CurrentDirectory%\GetGroupAdmins\SetFormattingEach.vbs
echo strNoHash = Replace(strHeaderText,strHash, strBlankText) >>%CurrentDirectory%\GetGroupAdmins\SetFormattingEach.vbs
echo strNewText = Replace(strNoHash,strXMLFooter, strFooterText) >>%CurrentDirectory%\GetGroupAdmins\SetFormattingEach.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\SetFormattingEach.vbs
echo Set objFile = objFSO.OpenTextFile(strFileName, ForWriting) >>%CurrentDirectory%\GetGroupAdmins\SetFormattingEach.vbs
echo objFile.WriteLine strNewText >>%CurrentDirectory%\GetGroupAdmins\SetFormattingEach.vbs
echo objFile.Close >>%CurrentDirectory%\GetGroupAdmins\SetFormattingEach.vbs
echo Done
echo.
echo.
echo Building Input script...
echo.
echo Dim Input >%CurrentDirectory%\GetGroupAdmins\in.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\in.vbs
echo Const ForReading = 1 >>%CurrentDirectory%\GetGroupAdmins\in.vbs
echo Const ForWriting = 2 >>%CurrentDirectory%\GetGroupAdmins\in.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\in.vbs
echo strFileName = "%CurrentDirectory%\GetGroupAdmins\GetAdmins.ps1" >>%CurrentDirectory%\GetGroupAdmins\in.vbs
echo strOldText = "~~Token~~" >>%CurrentDirectory%\GetGroupAdmins\in.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\in.vbs
echo Set objFSO = CreateObject("Scripting.FileSystemObject") >>%CurrentDirectory%\GetGroupAdmins\in.vbs
echo Set objFile = objFSO.OpenTextFile(strFileName, ForReading) >>%CurrentDirectory%\GetGroupAdmins\in.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\in.vbs
echo strInput = InputBox("Enter Your Token Here", "Token")  >>%CurrentDirectory%\GetGroupAdmins\in.vbs
echo MsgBox ("You entered: " ^& strInput) >>%CurrentDirectory%\GetGroupAdmins\in.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\in.vbs
echo strNewText = strInput >>%CurrentDirectory%\GetGroupAdmins\in.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\in.vbs
echo strText = objFile.ReadAll >>%CurrentDirectory%\GetGroupAdmins\in.vbs
echo objFile.Close >>%CurrentDirectory%\GetGroupAdmins\in.vbs
echo strNewText = Replace(strText, strOldText, strNewText) >>%CurrentDirectory%\GetGroupAdmins\in.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\in.vbs
echo Set objFile = objFSO.OpenTextFile(strFileName, ForWriting) >>%CurrentDirectory%\GetGroupAdmins\in.vbs
echo objFile.WriteLine strNewText >>%CurrentDirectory%\GetGroupAdmins\in.vbs
echo objFile.Close >>%CurrentDirectory%\GetGroupAdmins\in.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\in.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\in.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\in.vbs
echo Done
echo.
echo.
echo Building Text Replacement script...
echo.
echo Const ForReading = 1 >%CurrentDirectory%\GetGroupAdmins\replacetext.vbs
echo Const ForWriting = 2 >>%CurrentDirectory%\GetGroupAdmins\replacetext.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\replacetext.vbs
echo strFileName = Wscript.Arguments(0) >>%CurrentDirectory%\GetGroupAdmins\replacetext.vbs
echo strOldText = Wscript.Arguments(1) >>%CurrentDirectory%\GetGroupAdmins\replacetext.vbs
echo strNewText = Wscript.Arguments(2) >>%CurrentDirectory%\GetGroupAdmins\replacetext.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\replacetext.vbs
echo Set objFSO = CreateObject("Scripting.FileSystemObject") >>%CurrentDirectory%\GetGroupAdmins\replacetext.vbs
echo Set objFile = objFSO.OpenTextFile(strFileName, ForReading) >>%CurrentDirectory%\GetGroupAdmins\replacetext.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\replacetext.vbs
echo strText = objFile.ReadAll >>%CurrentDirectory%\GetGroupAdmins\replacetext.vbs
echo objFile.Close >>%CurrentDirectory%\GetGroupAdmins\replacetext.vbs
echo strNewText = Replace(strText, strOldText, strNewText) >>%CurrentDirectory%\GetGroupAdmins\replacetext.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\replacetext.vbs
echo Set objFile = objFSO.OpenTextFile(strFileName, ForWriting) >>%CurrentDirectory%\GetGroupAdmins\replacetext.vbs
echo objFile.WriteLine strNewText >>%CurrentDirectory%\GetGroupAdmins\replacetext.vbs
echo objFile.Close >>%CurrentDirectory%\GetGroupAdmins\replacetext.vbs
echo Done.
echo.
echo.
echo Building Concatonation script...
echo.
echo Const ForReading = 1 >%CurrentDirectory%\GetGroupAdmins\ConCatBuild.vbs
echo Const ForWriting = 2 >>%CurrentDirectory%\GetGroupAdmins\ConCatBuild.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\ConCatBuild.vbs
echo strFileName = "%CurrentDirectory%\GetGroupAdmins\Outputs.bat" >>%CurrentDirectory%\GetGroupAdmins\ConCatBuild.vbs
echo strOldText = ".xml" ^& vbcrlf >>%CurrentDirectory%\GetGroupAdmins\ConCatBuild.vbs
echo strNewText = ".xml + "  >>%CurrentDirectory%\GetGroupAdmins\ConCatBuild.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\ConCatBuild.vbs
echo Set objFSO = CreateObject("Scripting.FileSystemObject") >>%CurrentDirectory%\GetGroupAdmins\ConCatBuild.vbs
echo Set objFile = objFSO.OpenTextFile(strFileName, ForReading) >>%CurrentDirectory%\GetGroupAdmins\ConCatBuild.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\ConCatBuild.vbs
echo strText = objFile.ReadAll >>%CurrentDirectory%\GetGroupAdmins\ConCatBuild.vbs
echo objFile.Close >>%CurrentDirectory%\GetGroupAdmins\ConCatBuild.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\ConCatBuild.vbs
echo strText = "copy " ^& strText >>%CurrentDirectory%\GetGroupAdmins\ConCatBuild.vbs
echo strFirstPassText = Replace(strText, strOldText, strNewText) >>%CurrentDirectory%\GetGroupAdmins\ConCatBuild.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\ConCatBuild.vbs
echo strSecondOldText = "+ " ^& vbcrlf >>%CurrentDirectory%\GetGroupAdmins\ConCatBuild.vbs
echo strSecondNewText = "AllGroups.xml"  >>%CurrentDirectory%\GetGroupAdmins\ConCatBuild.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\ConCatBuild.vbs
echo strSecondPassText = Replace(strFirstPassText, strSecondOldText, strSecondNewText) >>%CurrentDirectory%\GetGroupAdmins\ConCatBuild.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\ConCatBuild.vbs
echo Set objFile = objFSO.OpenTextFile(strFileName, ForWriting) >>%CurrentDirectory%\GetGroupAdmins\ConCatBuild.vbs
echo objFile.WriteLine strSecondPassText >>%CurrentDirectory%\GetGroupAdmins\ConCatBuild.vbs
echo objFile.Close >>%CurrentDirectory%\GetGroupAdmins\ConCatBuild.vbs
echo Done.
echo.
echo.
echo Building Arrow deletion script...
echo.
echo Const ForReading = 1 >%CurrentDirectory%\GetGroupAdmins\NoArrow.vbs
echo Const ForWriting = 2 >>%CurrentDirectory%\GetGroupAdmins\NoArrow.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\NoArrow.vbs
echo strFileName = Wscript.Arguments(0) >>%CurrentDirectory%\GetGroupAdmins\NoArrow.vbs
echo strBlankText = "" >>%CurrentDirectory%\GetGroupAdmins\NoArrow.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\NoArrow.vbs
echo Set objFSO = CreateObject("Scripting.FileSystemObject") >>%CurrentDirectory%\GetGroupAdmins\NoArrow.vbs
echo Set objFile = objFSO.OpenTextFile(strFileName, ForReading) >>%CurrentDirectory%\GetGroupAdmins\NoArrow.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\NoArrow.vbs
echo strText = objFile.ReadAll >>%CurrentDirectory%\GetGroupAdmins\NoArrow.vbs
echo objFile.Close >>%CurrentDirectory%\GetGroupAdmins\NoArrow.vbs
echo strNewText = Replace(strText, Chr(26), strBlankText) >>%CurrentDirectory%\GetGroupAdmins\NoArrow.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\NoArrow.vbs
echo Set objFile = objFSO.OpenTextFile(strFileName, ForWriting) >>%CurrentDirectory%\GetGroupAdmins\NoArrow.vbs
echo objFile.WriteLine strNewText >>%CurrentDirectory%\GetGroupAdmins\NoArrow.vbs
echo objFile.Close >>%CurrentDirectory%\GetGroupAdmins\NoArrow.vbs
echo Done.
echo.
echo.
echo Building Overall final file formatting
echo Const ForReading = 1 >%CurrentDirectory%\GetGroupAdmins\SetFormattingLast.vbs
echo Const ForWriting = 2 >>%CurrentDirectory%\GetGroupAdmins\SetFormattingLast.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\SetFormattingLast.vbs
echo strFileName = Wscript.Arguments(0) >>%CurrentDirectory%\GetGroupAdmins\SetFormattingLast.vbs
echo strXMLHeader = "<?xml version=" ^& Chr(34) ^& "1.0" ^& Chr (34) ^& " encoding=" ^& Chr(34) ^& "UTF-8" ^& Chr(34) ^& "?>" >>%CurrentDirectory%\GetGroupAdmins\SetFormattingLast.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\SetFormattingLast.vbs
echo strHash = "<hash>" >>%CurrentDirectory%\GetGroupAdmins\SetFormattingLast.vbs
echo strXMLFooter = "</hash>" >>%CurrentDirectory%\GetGroupAdmins\SetFormattingLast.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\SetFormattingLast.vbs
echo Set objFSO = CreateObject("Scripting.FileSystemObject") >>%CurrentDirectory%\GetGroupAdmins\SetFormattingLast.vbs
echo Set objFile = objFSO.OpenTextFile(strFileName, ForReading) >>%CurrentDirectory%\GetGroupAdmins\SetFormattingLast.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\SetFormattingLast.vbs
echo strText = objFile.ReadAll >>%CurrentDirectory%\GetGroupAdmins\SetFormattingLast.vbs
echo objFile.Close >>%CurrentDirectory%\GetGroupAdmins\SetFormattingLast.vbs
echo strNewText = strXMLHeader ^& strHash ^& strText ^& strXMLFooter >>%CurrentDirectory%\GetGroupAdmins\SetFormattingLast.vbs
echo. >>%CurrentDirectory%\GetGroupAdmins\SetFormattingLast.vbs
echo Set objFile = objFSO.OpenTextFile(strFileName, ForWriting) >>%CurrentDirectory%\GetGroupAdmins\SetFormattingLast.vbs
echo objFile.WriteLine strNewText >>%CurrentDirectory%\GetGroupAdmins\SetFormattingLast.vbs
echo objFile.Close >>%CurrentDirectory%\GetGroupAdmins\SetFormattingLast.vbs
echo Done.
echo.
echo.
echo Building the Last make pretty PowerShell script.
echo (Get-Content "%CurrentDirectory%\GetGroupAdmins\Output\AllGroups.xml") ^| > %CurrentDirectory%\GetGroupAdmins\NormalizeText.ps1
echo Set-Content "%CurrentDirectory%\GetGroupAdmins\Output\AllGroups.xml" >> %CurrentDirectory%\GetGroupAdmins\NormalizeText.ps1
echo Done.
echo.
echo.
goto End
REM =====================================
REM =====================================
:FormatXML
set FileName=%1
REM copy /y %CurrentDirectory%\GetGroupAdmins\Output\%FileName% %CurrentDirectory%\GetGroupAdmins\Output\Formatted%FileName%
cscript //nologo %CurrentDirectory%\GetGroupAdmins\SetFormattingEach.vbs %CurrentDirectory%\GetGroupAdmins\Output\%FileName%
set FileName=
goto End
REM =====================================
REM =====================================
:End
0 Replies