Schlagwort: PowerShell
PowerShell: Configure some basic Windows settings after a fresh installation
After installing Windows I always started configuring the same old basic settings: move Desktop, Documents, Music, Videos, Pictures folders to D:\ configure some basic settings in Windows Explorer folder options (e.g. show hidden files, show file extensions) remove Internet Explorer from taskbar and add PowerShell to it Today I set…
Git ignores .gitignore when working with PowerShell
PowerShell: Check whether a Windows command or executable is available
In one of my recent PowerShell scripts I needed to find out if certain commands (in my case “svn”, “git”, “ant” and “mvn”) were available or not. I wrote this small function that tries to call the given command and returns whether it is callable. function commandAvailable($cmd, $options) { $error.clear();…
PowerShell: How to read contents from text files without converting the lines into an array
Apparently, PowerShell’s get-content cmdlet automatically converts the contents of text files into an array of strings, splitting the contents at the line breaks (see Using the Get-Content Cmdlet). In many cases this is convenient: Contents of file test.txt: 1 2 3 gc text.txt | % { write-host “line: ” $_…
Running PowerShell scripts from a UNC path without security warnings
Verweis auf mein PowerShell-Script in der aktuellen Ausgabe der hakin9
In der aktuellen Ausgabe der hakin9 verweist Hannes Schurig im Rahmen seines Artikels “Manuelle und automatisierte Administration einer Active Directory Domäne und Grundlagen der Gruppenrichtlinien” auf mein kleines PowerShell-Script zum Auslesen von Computern aus einem Active Directory. Danke für die Referenz! 🙂 Aber unabhängig von der kleinen Referenz hat Hannes…
web2bibtex.ps1: BibTeX-Einträge für Onlineartikel aus Fachzeitschriften generieren
Ich pflege mit Zotero eine Liste aller von mir gelesenen Fachartikel. Dazu ist es notwendig, die Metadaten dieser Artikel zu erfassen. Da ich jedoch wenig Spaß daran habe, das für mehrere Artikel pro Woche manuell zu tun, habe ich mir ein kleines PowerShell-Script geschrieben, das aus den Beschreibungen der Artikel…
PowerShell: Read user’s groups from Active Directory
Here’s a short PowerShell function to retrieve a list of a user’s groups from Active Directory: function getADGroups($username) { $root = ([adsi]””).distinguishedName; $searcher = new-object System.DirectoryServices.DirectorySearcher($root); $searcher.filter = “(&(objectClass=user)(sAMAccountName=$username))”; $user = $searcher.findall(); $groupNames = @(); if ($user.count -eq 1) { $groups = $user[0].Properties.memberof; [regex]$regex = “^CN=(.*?),”; $groups | % {…
PowerShell: Uninstall programs on a remote PC
Today I wanted to roll out Microsoft Office 2010 to a few clients but I needed to get rid of old Office installations on these systems because those could lead to problems while installing the new version. Instead of uninstalling them manually I wrote the following short PowerShell script UninstallOffice.ps1…
PowerShell: Configure some basic Windows settings after a fresh installation
After installing Windows I always started configuring the same old basic settings: move Desktop, Documents, Music, Videos, Pictures folders to D:\ configure some basic settings in Windows Explorer folder options (e.g. show hidden files, show file extensions) remove Internet Explorer from taskbar and add PowerShell to it Today I set…
Git ignores .gitignore when working with PowerShell
PowerShell: Check whether a Windows command or executable is available
In one of my recent PowerShell scripts I needed to find out if certain commands (in my case “svn”, “git”, “ant” and “mvn”) were available or not. I wrote this small function that tries to call the given command and returns whether it is callable. function commandAvailable($cmd, $options) { $error.clear();…
PowerShell: How to read contents from text files without converting the lines into an array
Apparently, PowerShell’s get-content cmdlet automatically converts the contents of text files into an array of strings, splitting the contents at the line breaks (see Using the Get-Content Cmdlet). In many cases this is convenient: Contents of file test.txt: 1 2 3 gc text.txt | % { write-host “line: ” $_…
Running PowerShell scripts from a UNC path without security warnings
Verweis auf mein PowerShell-Script in der aktuellen Ausgabe der hakin9
In der aktuellen Ausgabe der hakin9 verweist Hannes Schurig im Rahmen seines Artikels “Manuelle und automatisierte Administration einer Active Directory Domäne und Grundlagen der Gruppenrichtlinien” auf mein kleines PowerShell-Script zum Auslesen von Computern aus einem Active Directory. Danke für die Referenz! 🙂 Aber unabhängig von der kleinen Referenz hat Hannes…
web2bibtex.ps1: BibTeX-Einträge für Onlineartikel aus Fachzeitschriften generieren
Ich pflege mit Zotero eine Liste aller von mir gelesenen Fachartikel. Dazu ist es notwendig, die Metadaten dieser Artikel zu erfassen. Da ich jedoch wenig Spaß daran habe, das für mehrere Artikel pro Woche manuell zu tun, habe ich mir ein kleines PowerShell-Script geschrieben, das aus den Beschreibungen der Artikel…
PowerShell: Read user’s groups from Active Directory
Here’s a short PowerShell function to retrieve a list of a user’s groups from Active Directory: function getADGroups($username) { $root = ([adsi]””).distinguishedName; $searcher = new-object System.DirectoryServices.DirectorySearcher($root); $searcher.filter = “(&(objectClass=user)(sAMAccountName=$username))”; $user = $searcher.findall(); $groupNames = @(); if ($user.count -eq 1) { $groups = $user[0].Properties.memberof; [regex]$regex = “^CN=(.*?),”; $groups | % {…
PowerShell: Uninstall programs on a remote PC
Today I wanted to roll out Microsoft Office 2010 to a few clients but I needed to get rid of old Office installations on these systems because those could lead to problems while installing the new version. Instead of uninstalling them manually I wrote the following short PowerShell script UninstallOffice.ps1…