Skip to content

Commit 99d0d4e

Browse files
committed
Fixes an issue where Get-Resource does not correctly process a Guid value as the ID parameter
1 parent 3bb2294 commit 99d0d4e

File tree

7 files changed

+49
-34
lines changed

7 files changed

+49
-34
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,5 @@ GeneratedArtifacts/
188188
_Pvt_Extensions/
189189
ModelManifest.xml
190190
/src/packages
191+
192+
.vs/

src/Lithnet.ResourceManagement.Automation.Installer/Lithnet.ResourceManagement.Automation.Installer.wixproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<PreBuildEvent />
5252
</PropertyGroup>
5353
<PropertyGroup>
54-
<PostBuildEvent>"C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool\signtool.exe" sign /sha1 5ce168989b1359309dddee460c10e96fa60fa78b /t http://time.certum.pl /v $(TargetFileName)</PostBuildEvent>
54+
<PostBuildEvent>"C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool\signtool.exe" sign /sha1 "$(CSCERTTHUMBPRINT)" /t http://timestamp.digicert.com /fd sha256 /v "$(TargetFileName)"</PostBuildEvent>
5555
</PropertyGroup>
5656
<!--
5757
To modify your build process, add your task inside one of the targets below and uncomment it.

src/Lithnet.ResourceManagement.Automation.Installer/Product.wxs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<Product Id="*"
55
Name="Lithnet FIM/MIM Service PowerShell Module"
66
Language="1033"
7-
Version="1.0.6088"
7+
Version="!(bind.FileVersion.fil07BF703C3870C7016D35B71016C96B78)"
88
Manufacturer="Lithnet"
99
UpgradeCode="CC6C89F6-8663-46ED-A792-15B1327D8AA8">
1010
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

src/Lithnet.ResourceManagement.Automation/GetResource.cs

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -63,49 +63,59 @@ protected override void ProcessRecord()
6363
locale = new CultureInfo(this.Locale);
6464
}
6565

66-
UniqueIdentifier uniqueID = this.ID as UniqueIdentifier;
67-
68-
if (uniqueID != null)
66+
if (this.ID != null)
6967
{
70-
resource = RmcWrapper.Client.GetResource(uniqueID, this.AttributesToGet, locale);
68+
object item = null;
7169

72-
if (resource == null)
70+
if (this.ID is PSObject pso)
7371
{
74-
throw new ResourceNotFoundException();
72+
item = pso.BaseObject;
73+
}
74+
else
75+
{
76+
item = this.ID;
7577
}
7678

77-
this.WriteObject(new RmaObject(resource));
78-
return;
79-
}
80-
81-
string stringID = this.ID as string;
79+
if (item is UniqueIdentifier uniqueID)
80+
{
81+
resource = RmcWrapper.Client.GetResource(uniqueID, this.AttributesToGet, locale);
8282

83-
if (stringID != null)
84-
{
85-
resource = RmcWrapper.Client.GetResource(stringID, this.AttributesToGet, locale);
83+
if (resource == null)
84+
{
85+
throw new ResourceNotFoundException();
86+
}
8687

87-
if (resource == null)
88-
{
89-
throw new ResourceNotFoundException();
88+
this.WriteObject(new RmaObject(resource));
89+
return;
9090
}
9191

92-
this.WriteObject(new RmaObject(resource));
93-
return;
94-
}
92+
if (item is string stringID)
93+
{
94+
resource = RmcWrapper.Client.GetResource(stringID, this.AttributesToGet, locale);
9595

96-
Guid? guidID = this.ID as Guid?;
96+
if (resource == null)
97+
{
98+
throw new ResourceNotFoundException();
99+
}
97100

98-
if (guidID != null)
99-
{
100-
resource = RmcWrapper.Client.GetResource(guidID, this.AttributesToGet, locale);
101+
this.WriteObject(new RmaObject(resource));
102+
return;
103+
}
101104

102-
if (resource == null)
105+
if (item is Guid guidID)
103106
{
104-
throw new ResourceNotFoundException();
107+
resource = RmcWrapper.Client.GetResource(guidID, this.AttributesToGet, locale);
108+
109+
if (resource == null)
110+
{
111+
throw new ResourceNotFoundException();
112+
}
113+
114+
this.WriteObject(new RmaObject(resource));
115+
return;
105116
}
106117

107-
this.WriteObject(new RmaObject(resource));
108-
return;
118+
throw new ArgumentException($"The object type of the ID parameter was unknown. {this.ID.GetType().FullName}");
109119
}
110120

111121
if (this.AttributeValuePairs != null)

src/Lithnet.ResourceManagement.Automation/Lithnet.ResourceManagement.Automation.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<DebugSymbols>true</DebugSymbols>
2020
<DebugType>full</DebugType>
2121
<Optimize>false</Optimize>
22-
<OutputPath>C:\Windows\Sysnative\WindowsPowerShell\v1.0\Modules\LithnetRMA\</OutputPath>
22+
<OutputPath>bin\Debug\</OutputPath>
2323
<DefineConstants>DEBUG;TRACE</DefineConstants>
2424
<ErrorReport>prompt</ErrorReport>
2525
<WarningLevel>4</WarningLevel>
@@ -119,7 +119,10 @@
119119
</ItemGroup>
120120
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
121121
<PropertyGroup>
122-
<PostBuildEvent>"C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool\signtool.exe" sign /sha1 5ce168989b1359309dddee460c10e96fa60fa78b /t http://time.certum.pl /v $(TargetFileName)</PostBuildEvent>
122+
<PostBuildEvent>"C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool\signtool.exe" sign /sha1 "$(CSCERTTHUMBPRINT)" /t http://timestamp.digicert.com /fd sha256 /v "$(TargetFileName)"
123+
124+
"C:\Program Files\Debugging Tools for Windows (x64)\symstore" add /f "$(TargetDir)*.pdb" /s \\localhost\symbols /t "$(ProjectName)" /v "@(VersionNumber)"
125+
</PostBuildEvent>
123126
</PropertyGroup>
124127
<PropertyGroup>
125128
<PreBuildEvent>

src/Lithnet.ResourceManagement.Automation/LithnetRMA.Help.pshproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<ModuleObject xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" fVersion="1.1" type="Manifest" mclass="Module" useSupports="false">
33
<Name>LithnetRMA</Name>
4-
<Version>1.0.6048</Version>
4+
<Version>1.0.6596</Version>
55
<Description>Lithnet Resource Management Client for PowerShell</Description>
66
<HasManifest>true</HasManifest>
77
<OverridePostCount>false</OverridePostCount>

src/Lithnet.ResourceManagement.Automation/LithnetRMA.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
@{
1010

1111
# Version number of this module.
12-
ModuleVersion = '1.0.6088'
12+
ModuleVersion = '1.0.6596'
1313

1414
# ID used to uniquely identify this module
1515
GUID = 'd7c36446-aca6-418a-a2a3-cbfc32016a52'

0 commit comments

Comments
 (0)