Last active
December 12, 2023 20:04
-
-
Save infernoboy/7cc1fe26e647dd08e6e63a201cb38e27 to your computer and use it in GitHub Desktop.
Copied from a clean install of Windows 11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'--------------------------------------------------------------------------------------------- | |
' Copyright: Microsoft Corp. | |
' | |
' This script is designed to be used only for scheduled tasks(s). | |
' There is no extensive error check, and will not dump the output from the Powershell CmdLet. | |
' | |
' Usage: SyncAppvPublishingServer {cmdline-args(passthrough to cmdlet)} | |
'--------------------------------------------------------------------------------------------- | |
Option Explicit | |
Dim g_cmdArgs | |
g_cmdArgs = "" | |
' main entrance | |
' Enable error handling | |
On Error Resume Next | |
ParseCmdLine | |
if g_cmdArgs = "" Then | |
Wscript.echo "Command line arguments are required." | |
Wscript.quit 0 | |
End If | |
Dim syncCmd | |
syncCmd = "$env:psmodulepath = [IO.Directory]::GetCurrentDirectory(); " & _ | |
"import-module AppvClient; " & _ | |
"Sync-AppvPublishingServer " & g_cmdArgs | |
Dim psCmd | |
psCmd = "powershell.exe -NonInteractive -WindowStyle Hidden -ExecutionPolicy RemoteSigned -Command &{" & syncCmd & "}" | |
Dim WshShell | |
Set WshShell = WScript.CreateObject("WScript.Shell") | |
WshShell.Run psCmd, 0 | |
' Reset error handling | |
On Error Goto 0 | |
WScript.Quit 0 | |
'--------------------------------------------------------------------------------------------- | |
' Sub: ParseCmdLine | |
' Reading the parameters provided by the user in the command line | |
'--------------------------------------------------------------------------------------------- | |
Sub ParseCmdLine() | |
dim objArgs | |
dim argsCount | |
dim x | |
Set objArgs = Wscript.Arguments | |
argsCount = objArgs.count | |
x = 0 | |
While x < argsCount | |
g_cmdArgs = g_cmdArgs & " " & objArgs(x) | |
x = x + 1 | |
Wend | |
End Sub | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment