@@ -1138,26 +1138,31 @@ private void cleanUp()
1138
1138
1139
1139
private void validate ( )
1140
1140
{
1141
- if ( this . GenerateSshKey . IsPresent && ! this . IsParameterBound ( c => c . SshKeyName ) )
1141
+ if ( this . IsParameterBound ( c => c . SshKeyName ) )
1142
1142
{
1143
- throw new Exception ( "Please provide parameter '-SshKeyName' to be used with '-GenerateSshKey'" ) ;
1144
- }
1143
+ if ( this . ParameterSetName == "DefaultParameterSet" && ! IsLinuxOs ( ) )
1144
+ {
1145
+ throw new Exception ( "Parameters '-SshKeyName' and '-GenerateSshKey' are only allowed with Linux VMs" ) ;
1146
+ }
1145
1147
1146
- if ( this . ParameterSetName == "DefaultParameterSet" && ! IsLinuxOs ( ) )
1147
- {
1148
- throw new Exception ( "Parameters '-SshKeyName' and '-GenerateSshKey' are only allowed with Linux VMs" ) ;
1148
+ if ( this . ParameterSetName == "SimpleParameterSet" )
1149
+ {
1150
+ var client = new Client ( DefaultProfile . DefaultContext ) ;
1151
+ ImageAndOsType ImageAndOsType = client . UpdateImageAndOsTypeAsync (
1152
+ null , this . ResourceGroupName , this . Image , "" ) . Result ;
1153
+ if ( ImageAndOsType ? . OsType != OperatingSystemTypes . Linux )
1154
+ {
1155
+ throw new Exception ( "Parameters '-SshKeyName' and '-GenerateSshKey' are only allowed with Linux VMs" ) ;
1156
+ }
1157
+ }
1149
1158
}
1150
-
1151
- if ( this . ParameterSetName == "SimpleParameterSet" )
1159
+ else
1152
1160
{
1153
- var client = new Client ( DefaultProfile . DefaultContext ) ;
1154
- ImageAndOsType ImageAndOsType = client . UpdateImageAndOsTypeAsync (
1155
- null , this . ResourceGroupName , this . Image , "" ) . Result ;
1156
- if ( ImageAndOsType ? . OsType != OperatingSystemTypes . Linux )
1161
+ if ( this . GenerateSshKey . IsPresent )
1157
1162
{
1158
- throw new Exception ( "Parameters '-SshKeyName' and '-GenerateSshKey' are only allowed with Linux VMs " ) ;
1163
+ throw new Exception ( "Please provide parameter '-SshKeyName' to be used with '-GenerateSshKey' " ) ;
1159
1164
}
1160
- }
1165
+ }
1161
1166
}
1162
1167
}
1163
1168
}
0 commit comments