Skip to content

Commit 8aba3d6

Browse files
committed
New: Username and Password as commandline parameter
Use /username:xxx and /Password:xxx as arguments to pass credentials
1 parent 2f7febd commit 8aba3d6

5 files changed

Lines changed: 38 additions & 14 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ ASALocalRun/
323323

324324
#SCCCliCtr Files
325325
Customization.dll
326+
Customization.dll.config
326327
Plugin_*.dll
327328
Plugin_*/
328329
Customization/

SCCMCliCtrWPF/SCCMCliCtrWPF/MainPage.xaml.cs

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public MainPage()
205205
if (Properties.Settings.Default.showPingButton)
206206
bt_Ping.Visibility = System.Windows.Visibility.Visible;
207207

208-
208+
bool bNoConnect = true;
209209
try
210210
{
211211
if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
@@ -250,12 +250,16 @@ public MainPage()
250250
{
251251
if (Environment.GetCommandLineArgs().Count() > 0)
252252
{
253-
tb_TargetComputer.Text = Environment.GetCommandLineArgs()[1].Trim();
254-
tb_TargetComputer2.Text = Environment.GetCommandLineArgs()[1].Trim();
255-
tb_TargetComputer.Text = tb_TargetComputer.Text.Replace("-debug", "127.0.0.1");
256-
tb_TargetComputer2.Text = tb_TargetComputer.Text.Replace("-debug", "127.0.0.1");
257-
tb_TargetComputer.Text = tb_TargetComputer.Text.Replace("-Embedding", "");
258-
tb_TargetComputer2.Text = tb_TargetComputer2.Text.Replace("-Embedding", "");
253+
if (!Environment.GetCommandLineArgs()[1].StartsWith("/"))
254+
{
255+
tb_TargetComputer.Text = Environment.GetCommandLineArgs()[1].Trim();
256+
tb_TargetComputer2.Text = Environment.GetCommandLineArgs()[1].Trim();
257+
tb_TargetComputer.Text = tb_TargetComputer.Text.Replace("-debug", "127.0.0.1");
258+
tb_TargetComputer2.Text = tb_TargetComputer.Text.Replace("-debug", "127.0.0.1");
259+
tb_TargetComputer.Text = tb_TargetComputer.Text.Replace("-Embedding", "");
260+
tb_TargetComputer2.Text = tb_TargetComputer2.Text.Replace("-Embedding", "");
261+
bNoConnect = false;
262+
}
259263
}
260264
}
261265
}
@@ -271,7 +275,7 @@ public MainPage()
271275
if (Environment.GetCommandLineArgs().Count() > 1)
272276
{
273277
var Args = Environment.GetCommandLineArgs().ToList();
274-
bool bNoConnect = false;
278+
275279
if (Args.Contains("/RegisterConsole", StringComparer.OrdinalIgnoreCase))
276280
{
277281
try
@@ -295,6 +299,23 @@ public MainPage()
295299
return;
296300
}
297301

302+
string sUser = Args.FirstOrDefault(t => t.StartsWith("/Username:", StringComparison.CurrentCultureIgnoreCase));
303+
string sPW = Args.FirstOrDefault(t => t.StartsWith("/Password:", StringComparison.CurrentCultureIgnoreCase));
304+
305+
if (sUser != null && sPW != null)
306+
{
307+
sUser = sUser.Substring(10);
308+
sPW = sPW.Substring(10);
309+
if (!string.IsNullOrEmpty(sUser) && !string.IsNullOrEmpty(sPW))
310+
{
311+
tb_Username.Text = sUser;
312+
pb_Password.Password = common.Encrypt(sPW, Application.ResourceAssembly.ManifestModule.Name);
313+
sUser = "";
314+
sPW = "";
315+
}
316+
}
317+
318+
298319
if (!bNoConnect)
299320
{
300321
if (!string.IsNullOrEmpty(tb_TargetComputer.Text))
@@ -498,6 +519,7 @@ private void bt_Connect_Click(object sender, RoutedEventArgs e)
498519
}
499520
string sPW = common.Decrypt(pb_Password.Password, Application.ResourceAssembly.ManifestModule.Name);
500521
oAgent = new SCCMAgent(sTarget, tb_Username.Text, sPW, int.Parse(tb_wsmanport.Text), false, cb_ssl.IsChecked ?? false);
522+
sPW = "";
501523
}
502524

503525
oAgent.PSCode.Listeners.Add(myTrace);

SCCMCliCtrWPF/SCCMCliCtrWPF/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
5454
[assembly: AssemblyVersion("1.0.4.*")]
55-
[assembly: AssemblyFileVersion("1.0.4.1")]
55+
[assembly: AssemblyFileVersion("1.0.4.2")]

SCCMCliCtrWPF/SCCMCliCtrWPF/SCCMCliCtr.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
<WebPage>default.htm</WebPage>
4747
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
4848
<TrustUrlParameters>true</TrustUrlParameters>
49-
<ApplicationRevision>1</ApplicationRevision>
50-
<ApplicationVersion>1.0.4.1</ApplicationVersion>
49+
<ApplicationRevision>2</ApplicationRevision>
50+
<ApplicationVersion>1.0.4.2</ApplicationVersion>
5151
<UseApplicationTrust>true</UseApplicationTrust>
5252
<PublishWizardCompleted>true</PublishWizardCompleted>
5353
<BootstrapperEnabled>true</BootstrapperEnabled>
@@ -87,8 +87,8 @@
8787
<Private>True</Private>
8888
</Reference>
8989
<Reference Include="PresentationFramework.Aero" />
90-
<Reference Include="sccmclictr.automation, Version=1.0.0.11, Culture=neutral, processorArchitecture=MSIL">
91-
<HintPath>..\packages\sccmclictrlib.1.0.0.11\lib\net46\sccmclictr.automation.dll</HintPath>
90+
<Reference Include="sccmclictr.automation, Version=1.0.0.12, Culture=neutral, processorArchitecture=MSIL">
91+
<HintPath>..\packages\sccmclictrlib.1.0.0.12\lib\net46\sccmclictr.automation.dll</HintPath>
9292
</Reference>
9393
<Reference Include="System" />
9494
<Reference Include="System.Data" />
@@ -366,6 +366,7 @@
366366
<None Include="app.config">
367367
<SubType>Designer</SubType>
368368
</None>
369+
<Content Condition="Exists('Customization.dll.config')" Include="Customization.dll.config" />
369370
<None Include="packages.config" />
370371
<None Include="Properties\Settings.settings">
371372
<Generator>SettingsSingleFileGenerator</Generator>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="NavigationPane" version="2.1.0.0" targetFramework="net45" />
4-
<package id="sccmclictrlib" version="1.0.0.11" targetFramework="net46" />
4+
<package id="sccmclictrlib" version="1.0.0.12" targetFramework="net46" />
55
<package id="WPFToolkit" version="3.5.50211.1" targetFramework="net45" />
66
</packages>

0 commit comments

Comments
 (0)