@@ -156,29 +156,28 @@ object IDynamicParameters.GetDynamicParameters()
156
156
{
157
157
if ( this . PolicyDefinition != null )
158
158
{
159
- var properties = this . PolicyDefinition . Properties [ "Properties" ] ;
160
- if ( properties != null )
159
+ var parameters = this . PolicyDefinition . GetPSObjectProperty ( "Properties.parameters" ) as PSObject ;
160
+ if ( parameters != null )
161
161
{
162
- var parameters = ( properties . Value as PSObject ) . Properties [ "parameters" ] ;
163
- if ( parameters != null )
162
+ foreach ( var param in parameters . Properties )
164
163
{
165
- foreach ( var param in ( parameters . Value as PSObject ) . Properties )
164
+ var type = ( param . Value as PSObject ) . Properties [ "type" ] ;
165
+ var typeString = type != null ? type . Value . ToString ( ) : string . Empty ;
166
+ var description = ( param . Value as PSObject ) . GetPSObjectProperty ( "metadata.description" ) ;
167
+ var helpString = description != null ? description . ToString ( ) : string . Format ( "The {0} policy parameter." , param . Name ) ;
168
+ var dp = new RuntimeDefinedParameter
166
169
{
167
- var type = ( param . Value as PSObject ) . Properties [ "type" ] ;
168
- var typeString = type != null ? type . Value . ToString ( ) : string . Empty ;
169
- var dp = new RuntimeDefinedParameter
170
- {
171
- Name = param . Name ,
172
- ParameterType = typeString . Equals ( "array" , StringComparison . OrdinalIgnoreCase ) ? typeof ( object [ ] ) : typeof ( string )
173
- } ;
174
- dp . Attributes . Add ( new ParameterAttribute
175
- {
176
- Mandatory = false ,
177
- ValueFromPipelineByPropertyName = true ,
178
- HelpMessage = param . Name
179
- } ) ;
180
- this . dynamicParameters . Add ( param . Name , dp ) ;
181
- }
170
+ Name = param . Name ,
171
+ ParameterType = typeString . Equals ( "array" , StringComparison . OrdinalIgnoreCase ) ? typeof ( object [ ] ) : typeof ( string )
172
+ } ;
173
+ dp . Attributes . Add ( new ParameterAttribute
174
+ {
175
+ ParameterSetName = ParameterlessPolicyParameterSetName ,
176
+ Mandatory = true ,
177
+ ValueFromPipelineByPropertyName = true ,
178
+ HelpMessage = helpString
179
+ } ) ;
180
+ this . dynamicParameters . Add ( param . Name , dp ) ;
182
181
}
183
182
}
184
183
}
0 commit comments