-
Notifications
You must be signed in to change notification settings - Fork 0
/
GO_TEMPLATE.cmd
48 lines (38 loc) · 1.97 KB
/
GO_TEMPLATE.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
@Echo Off
SETLOCAL
:: Customize this file and save as GO.CMD (or save multiple versions as you like...)
:: Find your Log Analytics Workspace ID and key from the Azure portal https://portal.azure.com/
SET WORKSPACEID=12345678-blah-blah-blah-123456780123
SET WORKSPACEKEY=Base64encodingmeansthisisactuallyaSemiPlausibleOutcomebutthekeygoeshere==
:: ProxyURL format: http://nameOrIp:port or blank for no proxy
SET "PROXYURL="
:: eg SET "PROXYURL=http://10.1.1.1:3128"
:: Set the collection target type - defaults to AllRequests.
:: Other options: ActiveCertsBasic, IssuedCertsBasic
SET COLLECTIONTARGET=AllRequests
:: If you want to vary the table name, replace %COMPUTERNAME% with the new table name
:: Note TABLENAME must obey Log Analytics conventions, and the eventual tablename will have _CL appended
SET "TABLENAME="
:: Path to the PowerShell 7 (or later) executable. If in system PATH, just PWSH.EXE should suffice
SET "PWSHPATH=PS7\PWSH.EXE"
:: Want a backup of the intermediate CSV files? We can do that...
:: The folder will be created for you if it doesn't exist, so get it right!
SET "ExtraBackup="
:: e.g. SET "ExtraBackup=C:\ExtraLogs"
:: Create backup folder if needed
if NOT defined EXTRABACKUP goto PrepareAndRun
IF NOT EXIST %EXTRABACKUP% (
echo Creating %EXTRABACKUP%
MD %EXTRABACKUP%
)
:: Expand any required script parameters...
:PrepareAndRun
if defined PROXYURL (SET PROXYBIT= -ProxyServerURL %PROXYURL%) ELSE (SET PROXYBIT=" ")
if defined EXTRABACKUP (SET EXTRABIT= -ExportBackupPath %EXTRABACKUP%) ELSE (SET EXTRABIT=" ")
if NOT defined COLLECTIONTARGET SET COLLECTIONTARGET=AllRequests
if NOT defined TABLENAME SET TABLENAME=%COMPUTERNAME%
if /I "%1"=="NOUPLOAD" SET NOUPLOADBIT= -NoUpload
:: Run PowerShell 7 with the parameters above.
%PWSHPATH% -command "& {.\ExportCertificateData.ps1 -CollectionTarget %COLLECTIONTARGET% -TableName %TABLENAME% -WorkspaceID %WORKSPACEID% -WorkspaceKey %WORKSPACEKEY% %PROXYBIT% %EXTRABIT% %NOUPLOADBIT%}
:: And we're done!
ENDLOCAL