dell / iDRAC-Redfish-Scripting

Python and PowerShell scripting for Dell EMC PowerEdge iDRAC REST API with DMTF Redfish
GNU General Public License v2.0
598 stars 276 forks source link

[Question][Powershell][Set-OneBIOSAttributeREDFISH] How to override the value confirmation? #252

Closed oliverwolfat closed 1 year ago

oliverwolfat commented 1 year ago

Hello @texroemer

I have once again a question regarding the PowerShell Cmdlets. We currently have the CmdLet Set-OneBIOSAttributeREDFISH asking for confirmation. Is there a way to automate this? Set-OneBIOSAttributeREDFISH_Confirmation

I try to set SecureBoot, i understand that confirmation is necessary for such a setting, but is there a way i can pass my confirmation in advance to the CmdLet? The code line seems to be 345

Thanks in advance

KR Oliver

texroemer commented 1 year ago

Hi @oliverwolfat

I updated the cmdlet to remove the check if trying to set attribute to same value as current. I also updated arguments for get all attributes and attribute registry, changed from string to switch, no argument value is needed anymore.

Example of running updated cmdlet:

PS C:\> Set-OneBIOSAttributeREDFISH -idrac_ip 192.168.0.120 -idrac_username root -idrac_password calvin -attribute_name SecureBoot -attribute_value Disabled -reboot_server y

- INFO, SecureBoot current value is: Disabled, changing value to: Disabled

- PASS, statuscode 200 returned to successfully set attribute pending value
- PASS, statuscode 200 returned to successfully create job: JID_796066166994
- PASS, JID_796066166994 job ID marked as scheduled
- INFO, User selected to reboot the server now to apply the config changes
- INFO, server power state ON, performing graceful shutdown
- PASS, statuscode 204 returned to gracefully shutdown the server
- INFO, server still in ON state waiting for graceful shutdown to complete, polling power status again
- INFO, server still in ON state waiting for graceful shutdown to complete, polling power status again
- INFO, server still in ON state waiting for graceful shutdown to complete, polling power status again
- INFO, server still in ON state waiting for graceful shutdown to complete, polling power status again
- FAIL, retry count to validate graceful shutdown has been hit. Server will now perform a force off.
- PASS, statuscode 204 returned to force off the server
- PASS, statuscode 204 returned successfully to power ON the server

- INFO, cmdlet will now poll job ID every 15 seconds until marked completed

- INFO, current job status: Task successfully scheduled.
- INFO, current job status: Task successfully scheduled.
- INFO, current job status: Task successfully scheduled.
- INFO, current job status: Task successfully scheduled.
- INFO, current job status: Task successfully scheduled.
- INFO, current job status: Job in progress.
- INFO, current job status: Job in progress.
- INFO, current job status: Job in progress.
- INFO, current job status: Job in progress.
- INFO, current job status: Job completed successfully.

- PASS, JID_796066166994 job ID marked as completed!
  Job completed in @{Minutes=7; Seconds=21}

- PASS, statuscode 200 returned successfully to get attribute(s)
- PASS, SecureBoot attribute successfully set to Disabled

Thanks Tex

oliverwolfat commented 1 year ago

HI @texroemer,

Thank you for you effort in trying to fix it that quickly. I tried updating the affected Cmdlet, but afterwards I still got the confirmation dialog unfortunatly.

I will try this again later this week with dedicated test hardware. BIOS Version 2.10.2 IDRAC Version 6.10.30.00

KR Oliver

texroemer commented 1 year ago

Can you confirm you have version 7 installed?

PS C:\> Get-InstalledModule Set-OneBIOSAttributeREDFISH

Version              Name                                Repository           Description
-------              ----                                ----------           -----------
7.0.0                Set-OneBIOSAttributeREDFISH         PSGallery            Cmdlet using iDRAC with Redfish API to either set one BIOS attribute or get current value of BIOS attributes. ...
oliverwolfat commented 1 year ago

Hi @texroemer

Sry for the completly delayed response. I can't since i used the provided "create_dir_structure_download_iDRAC-Redfish_cmdlets.ps1" script to download them from github and copy them to "C:\Users\$os_username\Documents\$powershell_version\Modules\$i"

I however checked if the PSM Version matches the github repository and it does. When i however try to run the module in my script, the job i create gets stuck due to manual keyboard input being required. 2023-05-02 09_52_38-Remote Desktop Manager  SAMGDEPLOY 2023-05-02 09_53_01-Remote Desktop Manager  SAMGDEPLOY

KR Oliver

texroemer commented 1 year ago

Looks like the old cmdlet still exists on your system somewhere where Powershell is calling it. I just tested fresh OS Windows installation on a Dell server, installed the module and works, no user interactive prompt when trying to set same attribute value.

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows 
PS C:\Users\Administrator> Install-Module Set-OneBiosAttributeREDFISH                                                                                                                                 
NuGet provider is required to continue                                                             
PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program
Files\PackageManagement\ProviderAssemblies' or'C:\Users\Administrator\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install
the NuGet provider by running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201
-Force'. Do you want PowerShellGet to install and import the NuGet provider now?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change
its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to
install the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): y
PS C:\Users\Administrator> cd\
PS C:\> Set-OneBIOSAttributeREDFISH -idrac_ip 192.168.0.120 -idrac_username root -idrac_password calvin -get_one_attribute MemTest

- Attribute Name: MemTest, Current Value: Disabled

PS C:\> Set-OneBIOSAttributeREDFISH -idrac_ip 192.168.0.120 -idrac_username root -idrac_password calvin -attribute_name MemTest -attribute_value Disabled -reboot_server n

- INFO, MemTest current value is: Disabled, changing value to: Disabled

- PASS, statuscode 200 returned to successfully set attribute pending value
- PASS, statuscode 200 returned to successfully create config job: JID_830437672486
- PASS, JID_830437672486 job ID marked as scheduled
- INFO, User selected to not reboot the server now to apply the config changes. Job ID is still scheduled and will execute on next server reboot
PS C:\> Get-InstalledModule Set-OneBiosAttributeREDFISH

Version    Name                                Repository           Description
-------    ----                                ----------           -----------
7.0.0      Set-OneBIOSAttributeREDFISH         PSGallery            Cmdlet using iDRAC with Red... 

Thanks Tex

oliverwolfat commented 1 year ago

Hi Tex,

I just noticed my fatal flaw. IdracRedfishSupport.psm1 implements all Modules and is also installed when running the "create_dir_structure_download_iDRAC-Redfish_cmdlets.ps1" Installer script. When i manually updated the one module i needed it still got overwritten by IdracRedfishSupport.psm1.

My bad, I am really sorry for the inconvenience.

KR Oliver