# PowerShell sur macOS



### Installation:

```bash
$ brew cask install powershell
```

https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-macos?view=powershell-7



### Lancement:

```bash
$ pwsh
PowerShell 7.0.2
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/powershell
Type 'help' to get help.

PS /Users/bruno>
```

```powershell
PS /Users/bruno> $psversiontable

Name                           Value

----                           -----

PSVersion                      7.0.2
PSEdition                      Core
GitCommitId                    7.0.2
OS                             Darwin 19.5.0 Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
```



### Policy:

```powershell
PS /Users/bruno> Get-ExecutionPolicy -List | Format-Table -AutoSize                                                                                                                                                                                                                                           Scope ExecutionPolicy

----- ---------------

MachinePolicy    Unrestricted
   UserPolicy    Unrestricted
      Process    Unrestricted
  CurrentUser    Unrestricted
 LocalMachine    Unrestricted
```



```powershell
#PS /Users/bruno> dir env:\
PS /Users/bruno> Get-ChildItem Env:

Name                           Value

----                           -----

_                              /usr/local/bin/pwsh
__CF_USER_TEXT_ENCODING        0x1F5:0x0:0x1
CMAKE_PREFIX_PATH              /usr/local/Cellar/qt/5.14.1/lib/cmake/
COLORFGBG                      15;0
COLORTERM                      truecolor
COMMAND_MODE                   unix2003
CONDA_CHANGEPS1                no
DISPLAY                        /private/tmp/com.apple.launchd.QNw7JYXSQU/org.macosforge.xquartz:0
EDITOR                         nano
ENABLE_PDF_EXPORT              0
GOPATH                         /Users/bruno/go
HOME                           /Users/bruno
HOMEBREW_NO_AUTO_UPDATE        1
ITERM_PROFILE                  lscolor
ITERM_SESSION_ID               w0t3p0:6916F9BA-464C-4198-A7C2-5E2CBD028754
LANG                           fr_FR.UTF-8
LC_ALL                         en_US.UTF-8
LC_TERMINAL                    iTerm2
LC_TERMINAL_VERSION            3.3.11
LOGNAME                        bruno
LS_COLORS                      bd=38;5;68:ca=38;5;17:cd=38;5;113;1:di=38;5;30:do=38;5;127:ex=38;5;208;1:pi=38;5;126:fi=0:ln=target:mh=38;5;222;1:…
NVM_BIN                        /Users/bruno/.nvm/versions/node/v12.14.1/bin
NVM_CD_FLAGS                   -q
NVM_DIR                        /Users/bruno/.nvm
NVM_INC                        /Users/bruno/.nvm/versions/node/v12.14.1/include/node
OLDPWD                         /Users/bruno/.config/joplin
PATH                           /usr/local/microsoft/powershell/7:/Users/bruno/perl5/bin:/Users/bruno/.nvm/versions/node/v12.14.1/bin:/Users/bruno…
PERL_LOCAL_LIB_ROOT            /Users/bruno/perl5
PERL_MB_OPT                    --install_base "/Users/bruno/perl5"
PERL_MM_OPT                    INSTALL_BASE=/Users/bruno/perl5
PERL5LIB                       /Users/bruno/perl5/lib/perl5
PROMPT_EOL_MARK
PSModulePath                   /Users/bruno/.local/share/powershell/Modules:/usr/local/share/powershell/Modules:/usr/local/microsoft/powershell/7…
PWD                            /Users/bruno
SHELL                          /bin/zsh
SHLVL                          1
SSH_AUTH_SOCK                  /private/tmp/com.apple.launchd.1OMFyfGPss/Listeners
TERM                           xterm-256color
TERM_PROGRAM                   iTerm.app
TERM_PROGRAM_VERSION           3.3.11
TERM_SESSION_ID                w0t3p0:6916F9BA-464C-4198-A7C2-5E2CBD028754
TMPDIR                         /var/folders/35/tdnmp_0n43nfmr32h7m2b8kw0000gn/T/
USER                           bruno
VIRTUAL_ENV_DISABLE_PROMPT     12
XPC_FLAGS                      0x0
XPC_SERVICE_NAME               0
```



### $PSHOME

```powershell
PS /Users/bruno> $PSHOME
/usr/local/microsoft/powershell/7
```



```powershell
PS /Users/bruno> $profile
/Users/bruno/.config/powershell/Microsoft.PowerShell_profile.ps1
```

```powershell
PS /Users/bruno> $PROFILE | Get-Member -Type NoteProperty | Format-List

TypeName   : System.String
Name       : AllUsersAllHosts
MemberType : NoteProperty
Definition : string AllUsersAllHosts=/usr/local/microsoft/powershell/7/profile.ps1

TypeName   : System.String
Name       : AllUsersCurrentHost
MemberType : NoteProperty
Definition : string AllUsersCurrentHost=/usr/local/microsoft/powershell/7/Microsoft.PowerShell_profile.ps1

TypeName   : System.String
Name       : CurrentUserAllHosts
MemberType : NoteProperty
Definition : string CurrentUserAllHosts=/Users/bruno/.config/powershell/profile.ps1

TypeName   : System.String
Name       : CurrentUserCurrentHost
MemberType : NoteProperty
Definition : string CurrentUserCurrentHost=/Users/bruno/.config/powershell/Microsoft.PowerShell_profile.ps1
```



### .NET Core:

[.NET Core (macOS)](https://dotnet.microsoft.com/download#macos)

```bash
$ brew cask install dotnet-sdk
```

```bash
$ dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.1.301
 Commit:    7feb845744

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.15
 OS Platform: Darwin
 RID:         osx.10.15-x64
 Base Path:   /usr/local/share/dotnet/sdk/3.1.301/

Host (useful for support):
  Version: 3.1.5
  Commit:  65cd789777

.NET Core SDKs installed:
  3.1.301 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.1.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download
```





https://wilsonmar.github.io/powershell-on-mac/

https://techcommunity.microsoft.com/t5/windows-powershell/how-to-use-powershell-as-an-admin-in-macos/m-p/364123





https://github.com/joonro/Get-ChildItemColor

