En seguimiento a la pregunta cmd.exe , ¿cuál es el equivalente de PowerShell echo %cd%o Linux / Unix pwd?
En seguimiento a la pregunta cmd.exe , ¿cuál es el equivalente de PowerShell echo %cd%o Linux / Unix pwd?
Respuestas:
Además de Get-Locationy sus alias, también puede usar la variable automática $pwd.
La $pwdvariable es buena porque tiene acceso directo a los miembros de PathInfo. P.ej
$pwd.Path.PadLeft(80)
$pwd.Drive
Y si alguna vez quieres saber qué miembros hay, puedes canalizar el comando \ alias a 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;}
Es pwd. Puedes "stringificarlo" poniéndolo entre comillas. Más aún, se puede construir caminos, así: "$pwd\bin".
cdes suficiente. no es necesarioecho %cd%