Escolar Documentos
Profissional Documentos
Cultura Documentos
Comenzandomisprimeroscomandos.
Unavezinstalado,puedecomenzarajugarconelprograma.
Voyamostrarcmocrearaliasdecomandos(ponermipropionombrealoscomandos).
Pordefectoyahayvariosaliases.Porejemployouseenvezdelcomandogethelppara
tenerayudaelcomandomanytambinsepuedeusarelcomandohelp.Entoncesuno
puedecambiarelnombreasuscomandosycrearnuevos!.
Posteriormentemostrarecomocrearregistros,apagarservicios,procesos.
Comohacerholamundo
PSC:\>echoholamundo
Comohacerusarvariablesenpowershell
PSC:\>$var=holamundo
PSC:\>echo$var
Comoobtenerlaayudadeuncomando(ejemplodir)
Existentresmaneras
PSC:\>gethelpdir
PSC:\>mandir
PSC:\>helpdir
Paraobtenerunalistadetodosloscomandospowershell
PSC:\>gethelp*
Paraobtenerayudayejemplosdetodosloscomandospowershell
http://technet.microsoft.com/enus/library/dd347701.aspx
Mostrarlosdrivesdelsistema
GetPSDrive.
Estecomandopermitemostrartodoslosdrives.Enestaseccinlanovedadesque
podemosnavegarenelregistrodeWindows.
>Usodelalias
Paracambiardenombreadiferentescomandos:Powershellutilizaloquellamamosalias.
Unaliasesunsobrenombrequelepodemosponeralcomando.Porejemplo:
PSC:\>setaliasgetdrivegetpsdrive
Estotransformaalcomandogetpsdriveagetdrive.Deahoraenadelantesicorremosel
comando:
PSC:\>getdrive
Drivesrealizarlamismafuncindelcomandogetpsdrive.Parecelindono?.Estaba
emocionadohastaquemedicuentaquealcerrarelpowershell(conexit)yalabrirlode
nuevoyanofuncionabaminuevocomando.
Laformamsfcildesolucionarestoesusandoelprofile.Enelprofileseescribeel
comandoylisto.Sinembargosinotenemosprofilehayquecrearloyagregarnuestro
setaliasgetdrivegetpsdrive.
Paraversiexisteelprofile:
PSC:\>testpath$profile
Sisalefalsehayquecrearlocon:
PSC:\>NewItemPath$ProfileItemTypefileForce
Luegoeditamoselprofile:
PSC:\>Notepad$profile
Ahoraenelarchivonotepadcolocamosesto:
setaliasgetdrivegetpsdrive
Finalmente,salvamoselarchivoycerramosyabrimoselpowershell
>REGISTROS
Paranavegarenelregistrosepone:
PSC:\>cdhklm:
Pararegresaraldrivecydejardenavegarenelregistro:
PSC:\>c:
Paralimpiarlapantallaenpowershell
PSC:\>cls
Paraveriralregistrohkeylocalmachine
PSC:\>cdhklm:
Parairalregistrosoftware\clients\Calendar\MicrosoftOutlook\protocols
PSHKLM:\>cdsoftware\clients\Calendar\Microsoft*\
Protocols
Algoquenomeagradaesquenofuncionaelcd..paravolveratrstienequesercd..(con
elespaciocomoenUNIX/LINUX)
Paracrearunregistro:
PSHKLM:\software\clients\Calendar\MicrosoftOutlook\Protocols>mkdirreg_nuevo
Paravolveralarazenpowershell:
PSHKLM:\software\clients\Calendar\MicrosoftOutlook\Protocols>cd/
Paralistarlosregistrosdentroderegistros(existenvariasformas.GetChildItem,ls,dir,gci.
Las4danlosmismosresultados).
PSHKLM:\>GetChildItem
PSHKLM:\>ls
PSHKLM:\>gci
PSHKLM:\>dir
Paravolveraldiscoc
PSHKLM:\>c:
PROCESOS
Paramostrarunalistadeprocesos:
PSC:\>GetProcess
Paradetenerunproceso:
PSC:\>StopProcessprocessname[process]
Paralistarservicios:
>Servicios
PSC:\>Getservice
Parainiciarunservicio:
PSC:\>startservice[service_name]
Paradetenerunservicio:
PSC:\>stopservice[service_name]
EJECUCIONDESCRIPTS
Paraejecutaryhabilitarunscriptenpowershell
Primerocreeunarchivoquesellameprueba.ps1conelsiguientecontenido:
/*Esteprogramamuestraelmensajeholamundo*/
Echoholamundo
Pordefectolevaasalirunmensajedeerrorcuandotratedeejecutarlo:
PSC:\>./prueba.ps1
Parahabilitarlaejecucindescriptsyquenosalgaunmensajedeerror:
PSC:\>setexecutionpolicyunrestricted
Unavezhabilitado,laejecucinenpowershellfunciona:
PSC:\>./prueba.ps1
Paraejecutarunarchivodepowershellps1condobleclick.
Esteesunpoquitomsdifcildeloquepens.
Losarchivosdepowershell(Ps1)nofuncionancondobleclickasquehayqueinvocarlo
desdeelcmd.
Estoporrazonesdeseguridad.
Paso1.
Tenerunarchivoconextensinps1.Miarchivosevaallamarcreardir.ps1.Esteejemplo
creaundirectorioquesellamaDaniel.
Archivo:creardir.ps1
Contenido:mkdirDaniel
Paso2.Crearunarchivoconextensincmdquellamealarchivocreardir.ps1.
Archivo:createdir.cmd
Contenido:powershell.execommand.\creardir.ps1
Lonicoquequedaeshacerdobleclickenelcmd.
Paracrearuneventoenelvisordeeventos:
PSC:\DocumentsandSettings\user>EVENTCREATE/TERROR/ID1000/L
APPLICATION/D"TestError"
EstemensajelepermitirgeneraruneventodeerrorconID100enlacategoriade
aplicaciones.
Paraverloseventosdelvisordeeventosenpowershell:
PSC:\DocumentsandSettings\user>GetEventLoglogName"Application"
Esperoqueleshayagustado.Sitienendudasescribanaesteblog.Cualquierdudaselas
aclaro.
ListoparalaparteII?: