Réponses:
Outre Get-Locationet ses alias, vous pouvez également utiliser la variable automatique $pwd.
La $pwdvariable est agréable car vous avez un accès direct aux membres PathInfo. Par exemple
$pwd.Path.PadLeft(80)
$pwd.Drive
Et si jamais vous voulez savoir quels membres il y a, vous pouvez simplement diriger la commande \ alias vers Get-Member:
PS C:\Users\your-name-here\Desktop> pwd|Get-Member
TypeName: System.Management.Automation.PathInfo
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Drive Property System.Management.Automation.PSDriveInfo Drive {get;}
Path Property System.String Path {get;}
Provider Property System.Management.Automation.ProviderInfo Provider {get;}
ProviderPath Property System.String ProviderPath {get;}
Ça l'est pwd. Vous pouvez le "stringifier" en le mettant entre guillemets. Plus encore, vous pouvez construire des chemins comme ceci: "$pwd\bin".
cdsuffit. pas besoin deecho %cd%