Reputation: 1635
I have a very simple Powershell script that I am invoking from a Shell script to bootstrap an EC2 instance.
#user-data.ps1
#!/usr/bin/env pwsh
Install-Module -Name AWS.Tools.Installer -Force
Install-AWSToolsModule AWS.Tools.EC2 -CleanUp -Force
I can see the output from the Powershell script is very noisy and I want to silence these commands without hiding errors.
Redirecting to $null
is hiding errors too and I don't want this to be hard to debug.
Install-Module -Name AWS.Tools.Installer -Force > $null
--
#user-data.sh
#!/bin/bash
yum install -y dos2unix
yum install -y telnet
yum install -y tree
curl https://packages.microsoft.com/config/rhel/7/prod.repo | tee /etc/yum.repos.d/microsoft.repo
yum install -y powershell
pwsh /root/user-data.ps1 -NonInteractive
Upvotes: 1
Views: 7871
Reputation: 3923
Even redirecting to null doesn;t hide them in normal PS, but you could try:
$ProgressPreference = "SilentlyContinue"
Install-Module -Name ModuleName
The normal value for $ProgressPreference is "Continue" if you want to change it back
Upvotes: 2