-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix xDiskAccessPath issue when reattaching volume - Fixes #66 #70
Fix xDiskAccessPath issue when reattaching volume - Fixes #66 #70
Conversation
[CmdletBinding()] | ||
param () | ||
|
||
return $PSVersionTable.PSEdition -ieq 'Core' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edition is not reliable way to detect Nano.
Please use this code.
function Test-IsNanoServer
{
if(Test-Command -Name Get-ComputerInfo)
{
$computerInfo = Get-ComputerInfo
if("Server" -eq $computerInfo.OsProductType -and "NanoServer" -eq $computerInfo.OsServerLevel)
{
return $true
}
}
return $false
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is really good to know! Thanks and fixed.
$timeout = 30000 | ||
$start = [DateTime]::Now | ||
While ($partition.IsReadOnly ` | ||
-and ([DateTime]::Now - $start).TotalMilliseconds -lt $timeout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: You are creating a time span each iteration of the loop. Calculate the timeout as an absolute time and check if now
is still less than the calculated time.
Minor: you should use Get-Date instead of [DateTime]::Now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TravisEz13 - Good point! Change made. I've also changed the same loop code in xDisk.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nano detection is the only blocking issue.
[OutputType([Boolean])] | ||
[CmdletBinding()] | ||
param () | ||
if (Test-Command -Name Get-ComputerInfo) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test-command isn't built in
Doh! Of course! Thanks @TravisEz13 - fixed. |
build failed due to AppVeyor issue. Triggered rebuild. |
Thanks @TravisEz13 - I didn't notice this. |
@PlagueHO To answer your question about the PSSA issues, my preference would be to update to CIM cmdlets, but if the WMI cmdlets are really needed, then you can suppress the PSSA rule, and I will move this rule to the 'flagged' category and list this as an exception. |
@kwirkykat - TBH, I think the WMI cmdlets are only there to support legacy systems. I think they were added in Windows Server 2012/Windows 8. So dropping the WMI cmdlets will prevent this resource working on Windows Server 2008R2 and Windows 7. My feeling is that if people do really want to use this resource with these legacy OS's then they can use earlier versions of this module. Going forward I'd much rather drop the WMI cmdlets and just define a minimum requirement in the Readme.md . What do you reckon? |
@PlagueHO I agree with this 100% with that last paragraph. Drop the WMI cmdlets and those who aren't upgrading to newer OS's can continue to use the older module versions. |
This PR:
These are some PSSA violations still in xDisk and xDiskAccessPath:
The WMI cmdlets should be able to be removed because they are fallback cmdlets if CIM does not work. Removing these may prevent older the resources from working in older OS's though. Unfortunately there were no code comments stating why the WMI cmdlets were included. @kwirkykat , @mbreakey3 - what is the thinking of the DSC Team on this?
This change contains the following fixes:
The changes made to xDiskAccessPath could be also ported to xDisk and it would resolve #25 . I'll raise a separate issue to address this.
This change is