Using Get-Credential for secure removal of Kaspersky antivirus

I discovered some IT guy on our network has the following script in a place where anyone on the network can see it and obtain the admin password. (Replaced our network name and the actual pw obviously)

msiexec /x {7911E943-32CC-45D0-A29C-56E6EF762275} /qn KLLOGIN=ournetworkadministrator KLPASSWD=adminpw

I’m trying to find a more secure way of doing it using Get-Credential and then saving an encrypted version to a file and retrieving it as needed. If anyone’s wondering about the details of that, I learned about it in the following YouTube video.
https://www.youtube.com/watch?v=MVZAbQEkegU

I’ve so far been unable to reproduce what he does in the video. I’m getting errors when I try to use a credential I created even before I try to save it to and then retrieve it from a file. I’ve attempted it with various different formats for user “administrator”. I’m quite confident I’m entering the admin password correctly at the prompt.

Ex 1:
PS Z:> $creds = Get-Credential -Credential administrator@ournetwork

PS Z:> Connect-MsolService -Credential $creds

Connect-MsolService : The user name or password is incorrect. Verify your user name, and then type your password again.

At line:1 char:1

+ Connect-MsolService -Credential $creds

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : OperationStopped: (:) [Connect-MsolService], MicrosoftOnlineException

+ FullyQualifiedErrorId : 0x80048821,Microsoft.Online.Administration.Automation.ConnectMsolService

Ex 2: (adding .net)

PS Z:> $creds = Get-Credential -Credential [administrator@ournetwork.net](mailto:administrator@sakalcai.net)

PS Z:> Connect-MsolService -Credential $creds

Connect-MsolService : The user name or password is incorrect. Verify your user name, and then type your password again.

At line:1 char:1

+ Connect-MsolService -Credential $creds

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : OperationStopped: (:) [Connect-MsolService], MicrosoftOnlineException

+ FullyQualifiedErrorId : 0x80048821,Microsoft.Online.Administration.Automation.ConnectMsolService

Ex 3: (in quotes — same error w/ or w/out .net)

PS Z:> $creds = Get-Credential -Credential [“administrator@ournetwork.net](mailto:”administrator@sakalcai.net)”

PS Z:> Connect-MsolService -Credential $creds

Connect-MsolService : The user name or password is incorrect. Verify your user name, and then type your password again.

At line:1 char:1

+ Connect-MsolService -Credential $creds

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : OperationStopped: (:) [Connect-MsolService], MicrosoftOnlineException

+ FullyQualifiedErrorId : 0x80048821,Microsoft.Online.Administration.Automation.ConnectMsolService

submitted by /u/daletheitguy
[link] [comments]

Leave a Reply