Skip to content
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

The variable '$allPartition' cannot be retrieved because it has not been set. #27

Open
Daoofchaos opened this issue Oct 26, 2020 · 5 comments

Comments

@Daoofchaos
Copy link

Hey there,

When running the code on a 'test' directory (robo-copied 2 files 1 VHD & 1 VHDX from our FSLogix storage directories) using the following command: .\Invoke-FslShrinkDisk.ps1 -Path C:\Temp\Test -ThrottleLimit 1 -LogFilePath C:\Temp\VHDShrinkLogFile.csv

It runs but then spits this into the log file for every file: "The variable '$allPartition' cannot be retrieved because it has not been set."

I have read the other issues where the script is run on low compute machines, I'm running on a VM with 12 CPU but have added the ThrottleLimit 1 parameter in there as well.

Thoughts?

Thanks

@Daoofchaos
Copy link
Author

Still looking for an answer here.

@JimMoyle
Copy link
Contributor

So you are trying to run the script against a folder without the recurse flag, either pick a single disk, or use -Recurse.

@vinnikovsa
Copy link

sorry, but it is not related to -Recurse, i am experiencing same issue with script. Just as example

PS C:\Scripts> .\invoke-fslshrinkdisk.ps1 -Path D:\Profiles\nq_S-1-5-21-101500254-2653624075-3746861667-9024 -PassThru -Recurse

Name : ODFC_nq.VHDX
StartTime : 4:30:43 PM
EndTime : 4:30:43 PM
ElapsedTime(s) : 0.1
DiskState : The variable '$allPartition' cannot be retrieved because it has not been set.
OriginalSizeGB : 9
FinalSizeGB : 9
SpaceSavedGB : 0
FullName : D:\Profiles\nq_S-1-5-21-101500254-2653624075-3746861667-9024\ODFC_nq.VHDX

Name : Profile_nq.vhdx
StartTime : 4:30:43 PM
EndTime : 4:30:43 PM
ElapsedTime(s) : 0.1
DiskState : The variable '$allPartition' cannot be retrieved because it has not been set.
OriginalSizeGB : 1.72
FinalSizeGB : 1.72
SpaceSavedGB : 0
FullName : D:\Profiles\nq_S-1-5-21-101500254-2653624075-3746861667-9024\Profile_nq.vhdx

@limabone
Copy link

limabone commented Jun 8, 2021

I'm also getting this issue on occasion.

@caireagin
Copy link

I was getting this issue, and managed to track down the cause, at least in my environment. TLDR: ensure Microsoft Storage Spaces SMP service(smphost) is not disabled.

When stepping through the script, I found that "Get-Partition -DiskNumber $mountedDisk.Number" was returning an error:

get-partition : No MSFT_Partition objects found with property 'DiskNumber' equal to '3'.  Verify the value of the property and retry.
At line:1 char:1
+ get-partition -disknumber 3
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (3:UInt32) [Get-Partition], CimJobException
    + FullyQualifiedErrorId : CmdletizationQuery_NotFound_DiskNumber,Get-Partition

Drilling down a bit further, a straight get-partition returned no results. This lead me to a helpful reddit thread, which pointed out that smphost is required for the get-partition script to work.

If smphost is simply stopped, it will be started by the get-partition script, but in our case, it was disabled, preventing it from starting.

Microsoft has guidance on whether or not to disable the service located here, which recommends not to disable the service.

As far as the script goes, could we get a simple bit of error handling that checks if smphost is disabled, and throws a warning that it is required for the script to function if it is detected as disabled?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants