Jump to content

Johhny

Members
  • Content count

    8
  • Joined

  • Last visited

  1. Johhny

    Help with invoke-restmethod and '\' char

    Worked a treat. Thanks a lot. $Title = Read-Host 'Title new srv account' $UpdatedTitle=$Title.Replace('\','\\')
  2. Hi, I have a powershell script that we use for creating new accounts in AD and adding the password to PasswordState. It works OK, but I get an error if someone includes a \ in the title. Example code $jsonData = ' { "PasswordListID":"278", "Title":"'+ $($Title) +'", "UserName":"'+$($username)+'", "Description":"'+$($purpose)+'", "HeartbeatEnabled":true, "ValidationScriptID":"7", "generatepassword":true, "AccountTypeID":"65", "ADDomainNetBIOS":"test", "HeartbeatSchedule":"'+$($date)+'" }' $PasswordstateUrl = 'https://passwordstate.xxx.com/winapi/passwords' $result = Invoke-Restmethod -Method Post -Uri $PasswordstateUrl -ContentType "application/json" -Body $jsonData -UseDefaultCredentials With this data I get the error below { "PasswordListID":"278", "Title":"test\srvtest", "UserName":"srvtest12", "Description":"Test script", "HeartbeatEnabled":true, "ValidationScriptID":"7", "generatepassword":true, "AccountTypeID":"65", "ADDomainNetBIOS":"test", "HeartbeatSchedule":"17:04" } Invoke-Restmethod : [{"errors":[{"message":"Invalid API Call"},{"phrase":"Error = Object reference not set to an instance of an object.}]}] If I remove the \ from the Title then it works { "PasswordListID":"278", "Title":"test srvtest", "UserName":"srvtest12", "Description":"Test script", "HeartbeatEnabled":true, "ValidationScriptID":"7", "generatepassword":true, "AccountTypeID":"65", "ADDomainNetBIOS":"test", "HeartbeatSchedule":"17:04" } Any ideas how to get around this? I could just do a string replace and remove the \, but is it possible to make this work with the \ included? Best regards, Johhny
  3. Johhny

    Data Retention

    Perfect. Thanks a lot :-)
  4. Johhny

    Data Retention

    Hi, Is there a way to delete the audit logs after X days? We have users who are based in Germany where there are strict rules about how long data can be kept. https://www.bluecoat.com/resources/cloud-governance-data-residency-sovereignty/germany-data-privacy-laws Some of our users have reacted over that we keep the audit events in the system for longer than 90 days. Best regards, Johhny
  5. Johhny

    Bulk update email addresses

    Hi, That will work for me. A nice little scripting job for a Friday afternoon :-) Thanks :-)
×