Friday, 17 January 2025

Powershell Script Sign

 #Parameters
$CertificateName = "PowerShell Code Signing"
 
#Create a Self-Signed SSL certificate
$Certificate = New-SelfSignedCertificate -CertStoreLocation Cert:\CurrentUser\My -Subject "CN=$CertificateName" -KeySpec Signature -Type CodeSigningCert
 
#Export the Certificate to "Documents" Folder in your computer
$CertificatePath = [Environment]::GetFolderPath("MyDocuments")+"\$CertificateName.cer"
Export-Certificate -Cert $Certificate -FilePath $CertificatePath
 
#Add Certificate to the "Trusted Root Store"
Get-Item $CertificatePath | Import-Certificate -CertStoreLocation "Cert:\LocalMachine\Root"
 
Write-host "Certificate Thumbprint:" $Certificate.Thumbprint






=====================================================
#Set Parameters
$CertificateThumbprint = "40F84ACFDE3CAC51651E0BE793E8AF4F2B338343"
$ScriptPath = "C:\Users\kumar-ajeet\Downloads\test.ps1"
 
#Get the Certificate from Cert Store
$CodeSignCert = Get-ChildItem -Path Cert:\CurrentUser\My | Where-Object {$_.Thumbprint -eq $CertificateThumbprint}
 
#Sign the PS1 file
Set-AuthenticodeSignature -FilePath $ScriptPath -Certificate $CodeSignCert


Get-AuthenticodeSignature C:\Users\kumar-ajeet\Downloads\test.ps1 | fl

Cisco Bandwidth Limit

 Switch# configure terminal
Switch(config)# qos
Switch(config)# class-map match-all CLASS_ALL
Switch(config-cmap)# match any
Switch(config-cmap)# exit



Switch(config)# interface GigabitEthernet1/0/1
Switch(config-if)# service-policy input POLICY_LIMIT_150MB
Switch(config-if)# exit


Switch(config)# interface GigabitEthernet1/0/1
Switch(config-if)# service-policy output POLICY_LIMIT_150MB
Switch(config-if)# exit


Switch(config)# policy-map POLICY_LIMIT_100MB
Switch(config-pmap)# class class-default
Switch(config-pmap-c)# police cir 100000000 bc 3125000 conform-action transmit exceed-action drop
Switch(config-pmap-c)# exit

Switch(config)# policy-map POLICY_LIMIT_900MB
Switch(config-pmap)# class class-default
Switch(config-pmap-c)# police cir 900000000 bc 28125000 conform-action transmit exceed-action drop
Switch(config-pmap-c)# exit

Switch(config)# policy-map POLICY_LIMIT_850MB
Switch(config-pmap)# class class-default
Switch(config-pmap-c)# police cir 850000000 bc 26562500 conform-action transmit exceed-action drop
Switch(config-pmap-c)# exit


Switch(config)# policy-map POLICY_LIMIT_150MB
Switch(config-pmap)# class class-default
Switch(config-pmap-c)# police cir 150000000 bc 4687500 conform-action transmit exceed-action drop
Switch(config-pmap-c)# exit




Switch(config)# interface GigabitEthernet1/0/1
Switch(config-if)# service-policy input POLICY_LIMIT_850MB
Switch(config-if)# exit


Switch(config)# interface GigabitEthernet1/0/1
Switch(config-if)# service-policy output POLICY_LIMIT_850MB
Switch(config-if)# exit


Switch# show policy-map interface GigabitEthernet1/0/1

Switch# show policy-map interface