In seguito alla domanda cmd.exe , qual è l'equivalente di PowerShell echo %cd%o Linux / Unix pwd?
In seguito alla domanda cmd.exe , qual è l'equivalente di PowerShell echo %cd%o Linux / Unix pwd?
Risposte:
Oltre Get-Locatione i suoi alias, puoi anche usare la variabile automatica $pwd.
La $pwdvariabile è utile perché hai accesso diretto ai membri PathInfo. Per esempio
$pwd.Path.PadLeft(80)
$pwd.Drive
E se mai vuoi sapere quali membri ci sono, puoi semplicemente inoltrare il 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;}
Lo è pwd. È possibile "stringere" inserendolo tra virgolette. Più così, si può costruire percorsi come così: "$pwd\bin".
cdè abbastanza. non è necessarioecho %cd%