Tag Archives: powershell

How to fix Windows 10 Broken Search Bar

If your Windows 10 Search Bar is broken you’re encountering an issue that is spreading to many Windows 10 users at the time of this writing.

This is NOT an official statement (I’m not responsible for any side effects caused by this) about how to fix but running this script inside a PowerShell session with administrator privileges and restarting the machine can solve your issue (it worked on my machine).

Get-AppXPackage -Name Microsoft.Windows.Cortana | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}   

How to create a self-signed certificate with PowerShell

When we develop web-application or experiment with some technologies it’s quite common to need a certificate. A certificate for real world scenarios can be expensive and it’s over-engineering for testing purposes. So with this simple PowerShell script (on Windows) we can create a self-signed certificate for development enviroments.

$cert = New-SelfSignedCertificate -DnsName mydemowebapp.net -CertStoreLocation cert:\LocalMachine\My

$pwd = ConvertTo-SecureString -String "MyPassword" -Force -AsPlainText

Export-PfxCertificate -Cert $cert -FilePath C:\temp\cert.pfx -Password $pwd

With these few line of codes we create and store a self-signed certificate in the Windows Certificate Store. With the last line (Export-PfxCertificate) we export the certificate for furher use for example to do some experiments with cloud providers.

Reference

GitHub Gist

Toolbox al cioccolato

Per rendere utilizzabile ogni PC come si deve con tutta una serie di tools che a mio avviso ritengo indispensabili, utilizzo da qualche settimana uno script PowerShell.

Si basa su Chocolatey e infatti la prima riga dello script permette di installarlo.

Richiede di essere eseguito con PowerShell come Amministratore.

Ecco la mia lista di programmi di cui non posso fare a meno, ma soprattutto, lo script:

#Uncomment the following line to install Chocolatey.
#@powershell -NoProfile -ExecutionPolicy Bypass -Command “iex ((New-Object System.Net.WebClient).DownloadString(‘https://chocolatey.org/install.ps1′))” && SET “PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin”

choco install notepadplusplus -y

choco install vlc -y

choco install 7zip -y

choco install ultrasearch -y

choco install paint.net -y

choco install vim -y

choco install google-chrome-x64 -y

choco install windirstat -y

choco install autohotkey -y

choco install sysinternals -y

choco install teamviewer -y

choco install tor-browser  -y

#Less useful

#choco install ultravnc -y

#choco install ammyy -y

#choco install gitkraken -y

#choco install DotNet35 -y

#choco install DotNet45 -y

#choco install crystalreports-for-visualstudio -y

Aggiornare un servizio di Windows via Powershell

Avete implementato un servizio di Windows e, come è consuetudine, avete scoperto un bug e lo avete risolto.

Ora bisogna aggiornare il servizio.

Siccome il mio codice ha spesso dei bug mi è capitato di dover ripetere più volte questo processo:

  • Compila la dll con la correzione;
  • Spegni il servizio nel server;
  • Sostituisci la dll;
  • Riavvia il servizio.

All’n-esima volta mi sono stufato e ho creato uno script powershell che recita:

Set-Service -Name MadLab.Router -ComputerName 125.0.0.254 -Status Stopped

Copy-Item -Path .\MadLab.Router.Servizio\bin\Release\* -Destination \\125.0.0.254\madlab-ame\MadLab.Router\ -Exclude *config*,*vshost*, *.pdb

Set-Service -Name MadLab.Router -ComputerName 125.0.0.254 -Status Running