# Disable TlsCipher

**URL:** <https://forums.powershell.org/t/disable-tlscipher/20408>\
**Category:** PowerShell Help\
**Created:** [September 13, 2022, 1:29pm UTC](https://forums.powershell.org/t/disable-tlscipher/20408 "2022-09-13T13:29:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![psp](https://avatars.discourse-cdn.com/v4/letter/p/a5b964/32.png) [@psp](https://forums.powershell.org/u/psp)\
**Post date:** [September 13, 2022, 1:29pm UTC](https://forums.powershell.org/t/disable-tlscipher/20408/1 "2022-09-13T13:29:31Z")

</div>

Hi Folk,

I have created script to disable the Cipher i.e.

Disable-TlsCipherSuite -Name $Temp[$i]

As i am passing value of name property using array’s objects. It throwing error :  
Disable-TlsCipherSuite : Exception from HRESULT: 0xD0000225.

While if i am ruining same command by passing exact cipher name instead of using variable it’s working as expected.

I have already followed the article mentioned on “[powershell - Disable-TlsCipherSuite : Exception from HRESULT: 0xD0000225 - Stack Overflow](https://stackoverflow.com/questions/65213393/disable-tlsciphersuite-exception-from-hresult-0xd0000225)”

Could you please help to fix it.

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [September 13, 2022, 1:37pm UTC](https://forums.powershell.org/t/disable-tlscipher/20408/2 "2022-09-13T13:37:49Z")

</div>

Prabhat,  
Welcome to the forum. 👋🏽

> [@psp](#):
>
> Could you please help to fix it.

It may help if you post all of your code or at least the relevant part of the code you use. 😉

In the answer on StackOverflow you linked it is clamed that the error indicates that the cipher is already disabled. Did you try the solution postet there?

---

<div class="post-metadata">

**Author:** ![psp](https://avatars.discourse-cdn.com/v4/letter/p/a5b964/32.png) [@psp](https://forums.powershell.org/u/psp)\
**Post date:** [September 13, 2022, 1:44pm UTC](https://forums.powershell.org/t/disable-tlscipher/20408/3 "2022-09-13T13:44:21Z")

</div>

> [@Olaf](#):
>

Hi Olaf,

Thanks for responding. Below is the entire code.

```auto
$DESArray = Get-TlsCipherSuite|Format-Table -Property Name|findstr DES
$RC4Array = Get-TlsCipherSuite|Format-Table -Property Name|findstr RC4
$IDEAArray = Get-TlsCipherSuite|Format-Table -Property Name|findstr IDEA
$DisableCipher = $DESArray + $RC4Array + $IDEAArray
For ($i=0;$i -lt $DisableCipher.Length;$i++){
    Disable-TlsCipherSuite -Name $DisableCipher[$i]
}

```

yes, i did enable the cipher and tried the code again to disable same cipher i.e. passing cipher name as a variable but no luck and ended up with same error.

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [September 13, 2022, 2:17pm UTC](https://forums.powershell.org/t/disable-tlscipher/20408/4 "2022-09-13T14:17:50Z")

</div>

this works for me …

```auto
$SearchPatternList = 'DES', 'RC4', 'IDEA'
$ResultList =
foreach ($SearchPattern in $SearchPatternList) {
    $CipherSuite = Get-TlsCipherSuite -Name $SearchPattern
    if ($CipherSuite) {
        $CipherSuite |
        ForEach-Object {
            ((($_ | out-string) -split "\n" | 
                Select-String -Pattern 'name' -SimpleMatch | 
                Select-Object -ExpandProperty line ) -split ':')[1].trim()
        }
    }
}

foreach ($Result in $ResultList) {
    Disable-TlsCipherSuite -Name $Result
}

```

---

<div class="post-metadata">

**Author:** ![psp](https://avatars.discourse-cdn.com/v4/letter/p/a5b964/32.png) [@psp](https://forums.powershell.org/u/psp)\
**Post date:** [September 13, 2022, 2:34pm UTC](https://forums.powershell.org/t/disable-tlscipher/20408/5 "2022-09-13T14:34:21Z")

</div>

> [@Olaf](#):
>
> Thanks a lot for quick response !! It worked for me as well 🙂

Just curios to know where did i went wrong ☹

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [September 13, 2022, 3:54pm UTC](https://forums.powershell.org/t/disable-tlscipher/20408/6 "2022-09-13T15:54:20Z")

</div>

> [@psp](#):
>
> where did i went wrong

While I do not have any experience working with this kind of topic I have to admit that `Get-TlsCipherSuite` provides a weird output. So it is not that straight forward as usual.

Regardless of that you should never use format cmdlets like `Format-Table` and pipe their output to the next cmdlet. That has never worked AFAIK. 😉

The way you determined the names and put them together results in a big string with concatenated names - not in an array of strings.  
Run this:

```auto
$DESArray = Get-TlsCipherSuite|Format-Table -Property Name|findstr DES
$RC4Array = Get-TlsCipherSuite|Format-Table -Property Name|findstr RC4
$IDEAArray = Get-TlsCipherSuite|Format-Table -Property Name|findstr IDEA
$DisableCipher = $DESArray + $RC4Array + $IDEAArray

```

and ouput this:

```auto
$DisableCipher

```

How does it look?

The first thing you should do when you need to debug some code is to output the variables to the console and inspect them if they are what you’d expect them to be. 😉

---

<div class="post-metadata">

**Author:** ![psp](https://avatars.discourse-cdn.com/v4/letter/p/a5b964/32.png) [@psp](https://forums.powershell.org/u/psp)\
**Post date:** [September 14, 2022, 5:47am UTC](https://forums.powershell.org/t/disable-tlscipher/20408/7 "2022-09-14T05:47:13Z")

</div>

> [@Olaf](#):
>
> never use format cmdlets like `Format-Table` and pipe their output to the next cmdlet. That has never worked AFAIK.

noted!!

Thanks alot one again 🙂

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:16pm UTC](https://forums.powershell.org/t/disable-tlscipher/20408/8 "2024-05-16T20:16:36Z")

</div>

Closed on May 16, 2024, 8:16pm UTC


