-
Notifications
You must be signed in to change notification settings - Fork 1
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
[Bug] Variables are not converted when used as parameter inputs to functions #4
Comments
This one’s a little trickier to fix since I have to look for variables used in the command then backtrack to where they were defined - e.g. you might not have used $HKCURegistrySettings as the example shows, it could have been named anything. I know how to do it though, so it’ll be worked out soon! |
Renamed title - this is a more widespread issue that affects any command that requires transformation on the parameter, but the parameter is defined in a separate variable, e.g. these examples work: Invoke-HKCURegistrySettingsForAllUsers -RegistrySettings $HKCURegistrySettings {
Set-RegistryKey -Key 'HKCU\Software\Microsoft\Office\14.0\Common' -Name 'qmenable' -Value 0 -Type DWord -SID $UserProfile.SID
Set-RegistryKey -Key 'HKCU\Software\Microsoft\Office\14.0\Common' -Name 'updatereliabilitydata' -Value 1 -Type DWord -SID $UserProfile.SID
} Show-InstallationWelcome -CloseApps 'iexplore,winword,excel' But the variables are not converted in these examples: [ScriptBlock]$HKCURegistrySettings = {
Set-RegistryKey -Key 'HKCU\Software\Microsoft\Office\14.0\Common' -Name 'qmenable' -Value 0 -Type DWord -SID $UserProfile.SID
Set-RegistryKey -Key 'HKCU\Software\Microsoft\Office\14.0\Common' -Name 'updatereliabilitydata' -Value 1 -Type DWord -SID $UserProfile.SID
}
Invoke-HKCURegistrySettingsForAllUsers -RegistrySettings $HKCURegistrySettings $AppsToClose = 'iexplore,winword,excel'
Show-InstallationWelcome -CloseApps $AppsToClose |
I have support for this now in the following branch: It needs a little more testing before merging in, but it's looking promising - for any functions that require a parameter transformation, and a variable was supplied to the parameter, it will go back to where the variable was assigned. So this: [scriptblock]$HKCURegistrySettings = {
Set-RegistryKey -Key 'HKCU\Software\Test' -Name 'Test' -Value 0 -Type DWord -SID $UserProfile.SID
}
Invoke-HKCURegistrySettingsForAllUsers -RegistrySettings $HKCURegistrySettings Gets transformed to: [scriptblock]$HKCURegistrySettings = {
Set-ADTRegistryKey -Key 'HKCU\Software\Test' -Name 'Test' -Value 0 -Type DWord -SID $_.SID
}
Invoke-ADTAllUsersRegistryAction -ScriptBlock $HKCURegistrySettings This should in theory work for any parameter that has changed in v4, like -CloseApps on Show-InstallationWelcome - and it's these additional use cases that need to be verified. |
Prerequisites
PSAppDeployToolkit.Tools version
0.2.1
PSAppDeployToolkit version
4.0.3
Describe the bug
Using Convert-ADTDeployment it doesn't convert -SID $UserProfile.SID to $_.SID for Invoke-HKCURegistrySettingsForAllUsers \ Invoke-ADTAllUsersRegistryAction
[Installation] :: Failed to modify the registry hive for User [XXXX\XXXX] with SID [S-1-5-21-111111111-111111111-9999999999-XXXX]
Error Record:
Message : The variable '$UserProfile' cannot be retrieved because it has not been set.
FullyQualifiedErrorId : VariableIsUndefined,Invoke-ADTAllUsersRegistryAction
Steps to reproduce
1.Use Convert-ADTDeployment to an older script that is using invoke-HKCURegistrySettingsForAllUsers with the parameter -SID $UserProfile.SID
2.Run new install
3.Check log.
Environment data
The text was updated successfully, but these errors were encountered: