I would like to make sure only Administrator’s was shown the S-FTP link in the navigation.
I know I can make the restriction directly on the page, wrapping the entire page in the same if statement, but it would be nice to also remove the link from the navigation.
I’ve tried with multiple things, and it looks like “the main page” doesn’t read any global variables, I can’t use $Public:something or $Secret:something either.
Seems like a bug IMO.
Navigation is static and generated only when the dashboard is starting. Use -LoadNavigation instead. It’s called whenever the page is loaded and includes all user\dashboard state.
To be honest, this is confusing and trips a lot of people up but was done for backwards compat. We may change this to be only -Navigation and remove -LoadNavigation in v4. Then -Navigation could accept both an array of static values as well as a script block.
Error with dashboard script
Cannot process argument transformation on parameter 'LoadNavigation'. Cannot convert the "System.Object[]" value of type "System.Object[]" to type "UniversalDashboard.Models.Endpoint".
at <ScriptBlock>, C:\ProgramData\UniversalAutomation\Repository\dashboards\Tools\Tools.ps1: line 33
at <ScriptBlock>, <No file>: line 1
System.Management.Automation.ParameterBindingArgumentTransformationException: Cannot process argument transformation on parameter 'LoadNavigation'. Cannot convert the "System.Object[]" value of type "System.Object[]" to type "UniversalDashboard.Models.Endpoint". ---> System.Management.Automation.ArgumentTransformationMetadataException: Cannot convert the "System.Object[]" value of type "System.Object[]" to type "UniversalDashboard.Models.Endpoint". ---> System.Management.Automation.PSInvalidCastException: Cannot convert the "System.Object[]" value of type "System.Object[]" to type "UniversalDashboard.Models.Endpoint".
at System.Management.Automation.LanguagePrimitives.ThrowInvalidCastException(Object valueToConvert, Type resultType)
at System.Management.Automation.LanguagePrimitives.ConvertNoConversion(Object valueToConvert, Type resultType, Boolean recurse, PSObject originalValueToConvert, IFormatProvider formatProvider, TypeTable backupTable)
at System.Management.Automation.LanguagePrimitives.ConversionData`1.Invoke(Object valueToConvert, Type resultType, Boolean recurse, PSObject originalValueToConvert, IFormatProvider formatProvider, TypeTable backupTable)
at System.Management.Automation.LanguagePrimitives.ConvertTo(Object valueToConvert, Type resultType, Boolean recursion, IFormatProvider formatProvider, TypeTable backupTypeTable)
at System.Management.Automation.ArgumentTypeConverterAttribute.Transform(EngineIntrinsics engineIntrinsics, Object inputData, Boolean bindingParameters, Boolean bindingScriptCmdlet)
--- End of inner exception stack trace ---
at System.Management.Automation.ArgumentTypeConverterAttribute.Transform(EngineIntrinsics engineIntrinsics, Object inputData, Boolean bindingParameters, Boolean bindingScriptCmdlet)
at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
--- End of inner exception stack trace ---
at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
at System.Management.Automation.CmdletParameterBinderController.BindParameter(CommandParameterInternal argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags flags)
at System.Management.Automation.CmdletParameterBinderController.BindParameter(UInt32 parameterSets, CommandParameterInternal argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags flags)
at System.Management.Automation.CmdletParameterBinderController.BindParameters(UInt32 parameterSets, Collection`1 arguments)
at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1 arguments)
at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)
at System.Management.Automation.CommandProcessor.BindCommandLineParameters()
at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)
at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)
at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)
at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)