Ok,
I finally figured this out. I know itās not the best method, but I prefer this than having the wording āplain textā Hereās what I did in case someone needs to do the same.
I read that API tokens do not go well as a securestring. Here are some references:
https://jamesone111.wordpress.com/2020/04/10/transformers-for-powershell-parameters-which-take-secrets/, and https://github.com/Azure/azure-powershell/issues/25533.
So in order to get past this, I needed to create another variable as show below:
$testapi1 = [pscredential]::new(ātokenā,$yourtoken)
Youāre basically adding the pscredential above like youāre going to setup a username, but you put something like ātokenā or any wording as a placeholder for the username, then put the token in.
Then after you define the header you do something like this: $testheader.add(fog-user-tokenā,$testapi1.GetNetworkCredential().password)
Again itās not the best method, but I also read a way when you do read-host -aseecurestring and save your api there as a variable, you can dispose that variable so it doesnāt stay in memory.
$test.disposeof
If someone has any better ideas, please let me know as Iām always on here learning new things and want to share as well. This basically can be closed out.