background preloader

PowerShell Code Repository

PowerShell Code Repository

Manipulation des fichiers en VBA - Club des décideurs et professionnels en Informatique VBA propose des méthodes pour travailler sur les fichiers. Ces fonctions de bases telles que Dir, Name, etc. ont un comportement proche des commandes DOS. Malheureusement, elles sont beaucoup trop limitées et permettent, hélas, que très peu d'actions ou bien alors au prix d'un code lourd à maintenir. Afin d'étendre les possibilités en ce qui concerne la manipulation des fichiers et des répertoires, Microsoft à mis au point un ensemble d'objets regroupés au sein de la librairie Microsoft Scripting Runtime. Cet ensemble de classe hiérarchique possède une unique racine : le FileSystemObject, plus communément connu sous le nom de FSO. Bien qu'il s'agisse en fait du nom d'une classe, il n'est pas rare de voir le mot FSO désigner la technique d'accès aux fichiers dans sa globalité. La hiérarchie des objets de cette librairie peut être comparée à celle de l'explorateur Windows : des fichiers inclus dans des dossiers qui eux-mêmes sont inclus dans des disques. I-B-1. I-B-2. I-B-3. I-B-4. I-C-1.

WSUS Admin Module Verificado nas seguintes plataformas Este script foi testado nessas plataformas pelo autor. É muito provável que funcione nessas plataformas também. Se você tentar e ver que funciona em uma outra plataforma, adicione uma nota no script de discussãote para que os demais saibam. Suporte de colegas online Para obter suporte de colegas online, ingresse no The Official Scripting Guys Forum! Aviso de isenção de responsabilidade Não existe suporte para os script de exemplo em nenhum programa ou serviço de suporte padrão da Microsoft.

posh-git Speed Up Excel Automation with PowerShell - Hey, Scripting Guy! Blog Summary: Microsoft PFE, Georges Maheu, optimizes the Windows PowerShell script he presented yesterday. Microsoft Scripting Guy, Ed Wilson, is here. Our guest blogger today is Georges Maheu. Note: All of the files from today, in addition to files for the entire week are in a zip file in the Script Repository. Take it away Georges... Today, we look at scaling up yesterday’s script. The first version of the script was linear and simple but somewhat slow; it works well for a small to mid-size environment, but it does not scale well for larger environments. When doing security assessments, most of the time, only a subset of computers is considered. Unfortunately, I am not aware of profiler tools for Windows PowerShell. Another option is to use the Measure-Command cmdlet. After you instrument the original script, the following statistics are generated: WMI query: ~ 0.25 seconds for responding local computer WMI query: ~ 1.00 seconds for responding remote computer Ping dead computer: ~2.5 seconds

Get-AD Verified on the following platforms This script is tested on these platforms by the author. It is likely to work on other platforms as well. If you try it and find that it works on another platform, please add a note to the script discussion to let others know. Online peer support For online peer support, join The Official Scripting Guys Forum! Disclaimer The sample scripts are not supported under any Microsoft standard support program or service.

Top SharePoint Sites | SharePoint Branding Examples | Best SharePoint Design Examples | Free SharePoint Themes and Templates Export and Import PowerShell ISE Opened Files - Windows PowerShell Blog Unlike other tools, PowerShell ISE doesn’t have project files. Project files are a good way to set your environment up with a well known state. Thanks to the ISE Object Model, it is possible to add some project functionality. The script below has two main functions “Export-ISEState” and “Import-ISEState”. Even script contents for untitled files are saved. To save the current state (state = files and PowerShellTabs), use something like: Export-ISEState c:\temp\files.isexml To load the state later run: Import-ISEState c:\temp\files.isexml When exporting the current state the all titled files are saved with the script from my last post. For untitled files, the contents are saved. If you like it, you can add it to your profile (psedit $profile will edit the ISE profile) or to a module imported in your profile. Lucio Silveira [MSFT] function Save-AllISEFiles Saves all ISE Files except for untitled files. foreach($tab in $psISE.PowerShellTabs) foreach($file in $tab.Files) if(! $file.Save() Param # File 1:

Microsoft Exchange 2010 PowerShell Cookbook (Review) [easyazon-image align="left" asin="1849682461" locale="us" height="110" src=" width="89"]PowerShell is hands down one of the most important skills than an Exchange administrator can learn. You can do a lot in Exchange Server 2010 using the GUI administration tools, but eventually you’re going to have to drop into the shell to do some deeper administration or simply to save time on bulk admin. My first contact with PowerShell was when Exchange Server 2007 was released. Today I’m working on a team that manages an Exchange Server environment of over 80,000 mailboxes, so using PowerShell on a regular basis is pretty much mandatory. Well it looks like that book has finally arrived in Microsoft Exchange 2010 PowerShell Cookbook by Mike Pfeiffer. Mike is an Exchange MVP, a Microsoft Certified Master on Exchange 2010, and someone whose blog I’ve followed for quite a while now. PowerShell Key Concepts Summary

Importing and Exporting Credentials in PowerShell – Precision Computing One question that comes up fairly often when dealing with (or writing!) secure cmdlets is how to properly handle usernames and passwords. The solution there is to use (or make) the -Credential parameter of type PSCredential. A PSCredential object helps ensure that your password stays protected in memory, unlike cmdlets that accept a straight username / password combination. If a parameter is of type PSCredential, PowerShell supports several types of input: empty: If you supply no input to a mandatory -Credential parameter, PowerShell prompts you for the username and password.string: If you supply a string to the -Credential parameter, PowerShell treats it as a username and prompts you for the password.credential: If you supply a credential object to the -Credential parameter, PowerShell accepts it as-is. This is great for interactive use, but what if you want to write an automated script for a cmdlet that accepts a -Credential parameter? Problem Solution “CachedUser“,$password Discussion

Harnessing PowerShell's String Comparison and List-Filtering Features "Hmm. Wifi Hotspot!" When you are first learning PowerShell, it often seems to be an 'Alice through the looking-glass' world. Just the simple process of comparing and selecting strings can seem strangely obtuse. PowerShell is an outstanding successor to the Windows/DOS batch language. The tradeoff for this added power and flexibility, though, is an increased complexity: learning PowerShell is not a trivial undertaking. Please imagine what it is like for anyone falling into this particular rabbit hole. "Funny, the doors are getting smaller, but the size of Windows keeps growing." It was all very well to say "Program with me," but the wise little Alice was not going to do that in a hurry. “Let’s try listing all the files in the current directory. Both of those sound like convenient aliases, Alice surmised. “So now”, she mused, “I know that … Get-ChildItem -exclude *.dll,*.exe … will answer the original question. I started out in Accountancy, but then discovered Lisp

Emit-XML - Windows PowerShell Blog I was writing a demo yesterday and needed a quick and dirty way to generate some XML so I wrote the function below. This highlights a couple of changes that are coming up in CTP3 that I thought I would preview. 1) The keyword "cmdlet" is going away and we'll just have "function". The first Here-String starts the XML document with a "<Object>". function Emit-XML{Param ([Parameter(Mandatory=$true, ValueFromPipeline=$true)]$object) @"<Object>$( foreach ($p in $object |Get-Member -type *Property) { $Name = $p.Name $Value = $Object. Here is an usage example: PS> gsv alg | Emit-xml<Object> <Name>ALG</Name> <CanPauseAndContinue>False</CanPauseAndContinue> <CanShutdown>False</CanShutdown> <CanStop>False</CanStop> <Container></Container> <DependentServices></DependentServices> <DisplayName>Application Layer Gateway Service</DisplayName> <MachineName>. I have to admit - I am VERY excited by some of the stuff we are lined up to deliver to you in V2.

LDAP Query Basics Topic Last Modified: 2011-01-13 By William Taylor This article discusses Lightweight Directory Access Protocol (LDAP) queries, which can be useful, but confusing, when troubleshooting Microsoft® Exchange Server and its relationship to its directory. = (EQUAL TO) This LDAP argument means a certain attribute must be equal to a certain value to be true. While working with Exchange Server, you encounter situations that use LDAP strings. The following example illustrates how to search using Active Directory Users and Computers: Open Active Directory Users and Computers. This example attempts to find all objects that either have prez for their title or test for the start of their name. You can also search using LDP, which is included in Microsoft Windows Server™ 2003 and Windows® 2000 Server support tools. A dialog box appears that should have the correct value in the Base DN field. C:\>ldifde -d "DC=witaylorroot,DC=com" -f c:\output.txt -r "(&(objectClass=user)(mailNickName=jeff*))

A Module to Create Modules and Advanced Functions - Windows PowerShell Blog [1/3/09 Update - the original link to the attachment containing this code was broken but is now fixed. Sorry. jps] It is hard to overstate how important Modules and Advanced Functions are. If you are a PowerShell user - you need to take the time to learn these new mechanisms and use them as your first choice in implementing new functions. Advanced Functions provide help, parameter tab-completion, and cmdlet semantics that make it easy for other people to use your functions. Modules make it easy to package functions and use them in ways that they don't collide with each other. The only downside of using Modules and Advanced Functions is that they both require extra work when you start writing code. PS> Import-Module Module PS> Get-Command -Module Module CommandType Name Definition ----------- ---- ---------- Function New-GUID ... Begin { }#Begin Process { Throw "Not Yet Implemented" }#Process End { }#End New-ModuleTemplate does something similar for Modules. Enjoy!

Search Users from Multiple Domains Using a Common Attribute–PowerShell Script ~ Santhosh Sivarajan's Blog This script searches 2 Active Directory domains using a common matching attribute value (employeeID) and creates an out file with Source SamAccountName, Target SamAccountName and Name. You can use this script if you are performing user migrations and merging user accounts during the migration. Input file – Empid.csv – contains all employee IDs. Output file – UserInfo.txt - The script generates a TAB delimited file output which contains Source SamAccountName, Target SamAccountName and Name files. In this script I am using employeeID as the common attribute to search user account in the source (ss-infra.lab) and target (santhosh.lab) domains. Download: