Archives by Tag 'Powershell'

How to record everything you do in Powershell

By Andrei Ungureanu - Last updated: Friday, June 9, 2017

Comanda Start-Transcript poate fi folosita pentru a comanda pornirea unui transcript in sesiunea curenta powershell si este o metoda foarte buna de a loga toate actiunile pe care le faceti pe un sistem din powershell. Pornita fara nici un parametru, comanda Start-Transcript va incepe logarea tuturor comenzilor si a outputlui din sesiunea curenta intr-un fisier […]

Copy the last powershell command to clipboard

By Andrei Ungureanu - Last updated: Wednesday, June 7, 2017

Sunt situatii in care am testat o comanda in Powershell si dorim sa o copiem pentru a fi trimisa unui coleg sau pentru a fi pusa intr-un script. Iar cand este foarte lunga, a face select si copy/paste e un proces destul de lent. Solutia este sa folosim history-ul din Powershell (Get-History aka R) si […]

Check if a string is null or empty

By Andrei Ungureanu - Last updated: Tuesday, April 18, 2017

Cand lucrezi cu string-uri in Powershell de multe ori vrei sa verifici daca nu cumva string-ul este null sau contine spatii sau tab-uri. O varianta ar fi sa verifici dimensiunea lui sau sa iei fiecare caracter in parte si sa il compari. Sau exista si o varianta mai simpla, folosind o metoda .Net – IsNullOrWhiteSpace. […]

Emulate NET VIEW behaviour from Powershell

By Andrei Ungureanu - Last updated: Tuesday, February 14, 2017

Am fost pus de multe ori in situatia in care am avut nevoie sa listez share-uri de pe un sistem remote folosind un script, si cu toate ca un simplu utilizator poate face asta foarte simplu din Windows Explorer, din linie de comanda sunt foarte putine optiuni. Una dintre ele ar fi folosind NET VIEW. […]

Optimizing Powershell functions by using a filter function

By Andrei Ungureanu - Last updated: Wednesday, February 1, 2017

Cred ca cel mai bine ar fi sa incep explicand cum preia o functie input-ul ce vine prin pipeline. In mod normal o functie in powershell poate sa preia input din pipeline folosind variabila $Input. Si daca trimitem ceva prin pipeline catre functie iata ce obtinem: Pare normal, nu-i asa? Dar iata ce se intampla […]

Again about troubleshooting AD Powershell queries – This operation returned because the timeout period expired,Microsoft.ActiveDirectory.Management.Commands.GetADUser

By Andrei Ungureanu - Last updated: Saturday, November 19, 2016

I was previously writing about some timeouts when getting data from Active Directory using Powershell cmdlets. Another thing that usually pops up when dealing with large amounts of data in AD is a default timeout of 2 minutes for each page search. This means that the time spend by the server to retrieve a page […]

Intro to handling errors in Powershell–default variables

By Andrei Ungureanu - Last updated: Wednesday, October 26, 2016

In majoritatea cazurilor, adminii nu prea ajung in zona de error handling, pentru ca multe din interactiunile cu Powershell se rezuma la a compune comenzi intr-o singura linie iar errorile le trateaza ad hoc. Dar chiar si atunci e bine sa stii cate ceva despre mecanismele din Powershell care te pot ajuta. Cel mai simplu […]

Troubleshooting AD Powershell queries: server has returned the following error – invalid enumeration context

By Andrei Ungureanu - Last updated: Saturday, October 22, 2016

I’ve seen a lot on the web about the error in the title (server has returned the following error – invalid enumeration context) and the reason I am writing about this is because there is a lot of confusion about this. You might see this error when you try to query AD from powershell (get-aduser, […]

How to bypass Powershell execution policy

By Andrei Ungureanu - Last updated: Tuesday, October 11, 2016

Restrictiile pe execution policy din powershell nu au fost niciodata gandite ca un mod absolut de a bloca rularea scripturilor. Este mai mult ca o protectie si pentru end user si pentru administratori de a nu rula ceva accidental. Si chiar daca pentru a seta execution policy pe Unrestricted cere drept de admin: Asta nu […]

Powershell on Linux

By Andrei Ungureanu - Last updated: Friday, August 19, 2016

Powershell pe Linux clar va schimba multe iar MS va fi vazut in cu totul alta lumina. https://azure.microsoft.com/en-us/blog/powershell-is-open-sourced-and-is-available-on-linux/ PS: de fapt portarea .Net pe Linux este baza si de aici vor urma multe altele.