My current command in Powershell with the Script Resource is as follows: (which does not work)
SetScript = {
Invoke-WebRequest "https://CHECKMKSERVER/SITENAME/check_mk/webapi.py?action=add_host&_username=USER&_secret=SECRET" -Method Post -Body 'request={"hostname":"$env:computername","folder":"","attributes":{"alias":"$env:computername","ipaddress":"IPADDRESSDestinationNode","site":"SITENAME","tag_agent":"cmk-agent","tag_os":"OSSYSTEM"}}'
}
The problems are
$env:computername - will not be interpreted as a Variable in the String Request, how can i achieve this? (I tried some solutions from the internet, but nothing worked so far)
IPADDRESS - how could I pass the IP address here?
And is there a simple solution for encrypting the secret in the powershell script?
Regarding the encryption, i have implemented the necessary commands. What I do not quite understand yet, how I pass over the encrypted secret correctly.
My destination nodes have a suitable CertificateFile, the Nodes Configuration data contains the path to the certificate and the thumbprint. Then i add the matching thumbprint for each node to the meta.mof with the following command.
Then I have added this at the beginning of my config and if i execute the script it asks me for user and password - but why user ? I just want to encrypt the password?