Geeks With Blogs

News

qrcode

Lance Robinson

Create Your Badge

Lance Robinson is a software engineer in Durham, Chapel Hill, Raleigh, and surrounding areas. More about Lance.

 Subscribe


Lance's TextBox » About Me » My Resume »Twitter NetCmdlets There are 39 entries for the tag NetCmdlets
10 PowerShell One Liners
Here are a few one-liners that use NetCmdlets. Some of these I've blogged about before, some are new. Let me know if you have questions, which ones you find useful, or how you altered these to suit your own needs. Send email to a list of recipient addresses: import-csv users.csv | % { send-email -to $_.email -from lance@nsoftware.com -subject "Important Email" –message "Hello World!" -server 10.0.1.1 } Show the access control list for a specific Exchange folder: get-imap -server $mymailserver -cred ......

Posted On Tuesday, December 29, 2009 4:36 AM

PowerShell Command Line Emailer
I’ve talked about this before, but it came up again today so I thought I’d do a quick post about it. Here’s a function I use in my PowerShell profile that uses NetCmdlets to send quick “todo” emails: function todo($target="work", $msg) { switch ($target) { "work" { $target = "lancer@nsoftware.com" } "home" { $target = "lmrobins@gmail.com" } } send-email -from lancer@nsoftware.com -to $target -subject ("Todo: " + $msg) -message $msg -server 10.0.1.1} During the day, when I need to send myself a reminder, ......

Posted On Tuesday, October 20, 2009 8:07 AM

5 PowerShell Oneliners to Manage IMAP Permissions
You can manage user permissions in Exchange and other mail servers with the same commands by using the IMAP protocol instead of server-specific tools. Here is how! Jumping right in, these all use get-imap and set-imap from NetCmdlets: #1 – Get ACL Here’s a one-liner to get the ACL for a specific folder in an account. In this particular case, my main INBOX has a subfolder named RESUMES, and I want to see who has what permissions to this folder. PS C:\> get-imap -server $mymailserver -cred $mycred ......

Posted On Thursday, June 4, 2009 11:11 AM

PowerShell: sync system time with Internet time server
NetCmdlet’s get-time cmdlet uses the Internet TIME protocol to query Internet time server’s for the current time. It can also be used to sync the time on the local system with that of the time server. The following PowerShell function gets the time on a time server, optionally syncs the local system to that time, and outputs both times to the console: 1: function sync-time( 2: [string] $server = "clock.psu.edu", 3: [int] $port = 37, 4: [switch] $set = $false) 5: { 6: $servertime = get-time -server ......

Posted On Monday, March 30, 2009 10:13 AM

New NetCmdlets and PowerShell Server Releases
The new NetCmdlets v2 and PowerShell Server v2 are now available! NEW: NetCmdlets V2 and PowerShell Server V2 NetCmdlets V2 is packed full of exciting new features including Parameter Sets, Object Pipelining, and new Cmdlets for SSH connectivity and Amazon Web Services (S3) Integration PowerShell Server instantly enables Windows desktops and servers with an SSH secured PowerShell host entrypoint. Try out the new featues in NetCmdlets V2 and PowerShell Server: download a 30-day trial! If you are already ......

Posted On Monday, December 22, 2008 3:08 PM

PowerShellPlus
So I’ve been using PowerShellPlus for the last few days, and in short – its awesome. The ability to put my script editor on one monitor, click run right there and see the results of the script on the other monitor made me very happy. :) If you haven’t checked it out, you definitely should. Its basically an integrated development environment for PowerShell scripting and debugging. A PowerShell console combined with an editor complete with watch window and step-through debugger. As soon as you type ......

Posted On Wednesday, October 8, 2008 10:24 AM

Deleting emails from PowerShell
The question was posed on the newsgroup: how do I delete emails (over POP or IMAP) on a remote mail server through PowerShell? Here’s an example of one way to do it – through the use of the get-imap, set-imap, and get-pop cmdlets that are included in NetCmdlets. ## deleteemail.ps1: Delete all email from a particular sender ## deletes emails from an IMAP or POP server. ## Returns a collection of objects containing information about deleted emails (from, to, subject) or mailboxes (name, flags) in a ......

Posted On Wednesday, September 24, 2008 3:44 PM

PowerShell: ESPN-Download
“Quintas" was another of the winners of the PowerScripting Podcast’s NetCmdlets scripting contest. Quintas submitted an espn-download script, which retrieves podcast feeds from espn.com and downloads the mp3 files for later listening. Here is Quintas’ script: # ESPN-Download param($DownloadDir=$(throw "Usage: ESPN-Download.ps1 DownloadDirectory Show LatestorAllDownloaded`nShow... Mike & Mike`n2. PTI`n3. Around The Horn`n`n[L] for latestshow or [ A ] for All shows`n"), [string]$ESPNShow=$(Read-Host ......

Posted On Thursday, September 11, 2008 4:46 PM

PowerShell NetCmdlets -debug
Its easy to forget about the –debug parameter, but a lot of times it can be very helpful, especially with NetCmdlets where in many cases –debug will output the protocol interface (the “PITrail” as we call it at /n software) of the connection. The PITrail includes a trail of communication between the cmdlet and the remote host it is talking to. Rob emailed me to ask for help diagnosing a 425 error he was getting when using the NetCmdlets get-ftp cmdlet. As I described to Rob, in a nutshell the 425 ......

Posted On Thursday, September 11, 2008 4:41 PM

PowerShell: tweet-im
Mark Schill was another of the winners of the PowerScripting Podcast’s NetCmdlets scripting contest. Mark submitted a tweet-im script, which sends an instant message about new tweets found in the Twitter RSS feed. They explained on the podcast that Twitter used to have an IM-bot feature which went away, so Mark created this script himself to meet this need. The script simply sits and fetches your Twitter friends timeline feed every x seconds, checks to see if the items it finds are newer than the ......

Posted On Thursday, September 11, 2008 10:56 AM

PowerShell: send-gmail
Over at the PowerScripting Podcast, the winners of the NetCmdlets scripting contest were announced. Meanwhile I was having some awesome vacation time in the beautiful Outer Banks of North Carolina. Winners for the /n software Netcmdlets contest are: Steve Hiner - Wrote a wrapper for Send-Email script to send email using Gmail's SMTP server Mark Schill - Sent in two entries, the one we've chosen to highlight is his Twitter IM client bot thingy. It uses Send-IM and Get-Http Quintus - A script to download ......

Posted On Wednesday, September 10, 2008 5:28 PM

PowerShell – Base64 Encode/Decode a string
An easy way to convert data to/from base64 (or uuencode/uudecode, quoted-printable, url encode/url decode, JIS, Yenc, hex, or even creating md5 or sha1 hashes) is to use the NetCmdlets convert-data cmdlet. To encode: PS C:\> convert-data -data "Hello, World!" -to base64 Data Size Format ---- ---- ------ SGVsbG8sIFdvcmxkIQ== 20 base64 To decode: PS C:\> convert-data -data $encoded.Data data -from base64 Data Size Format ---- ---- ------ Hello, World! 13 Plain Technorati Tags: PowerShell, NetCmdlets, ......

Posted On Friday, August 29, 2008 1:24 PM

test-remotepath.ps1
One of the cmdlets I use most often in my scripts is test-path, which simply tells you whether or not a particular file or path exists. Below is test-remotepath, which I use to tell me if a remote file or path exists. This particular script uses get-ftp from NetCmdlets, but it could also just as easily be done with rexec, rshell, or even ssh (sexec). ## test-remotepath.ps1: Tests if a remote file/path exists ## This script uses ftp to determine whether or not a remote file or path exists. ## This ......

Posted On Monday, August 25, 2008 5:23 PM

PowerScripting Podcast – Scripting Contest!
Update: deadline pushed back (another week?) for the scripting contest. In case you missed it, the guys over at the PowerScripting Podcast are hosting a scripting contest. Hurry though, the deadline is Sunday! They’re giving away free licenses of NetCmdlets and PrimalScript 2007. Technorati Tags: PowerShell, NetCmdlets ......

Posted On Friday, August 15, 2008 11:04 AM

NetCmdlets Invoke-Telnet?! And other PowerShell madness.
On last week’s PowerScripting Podcast, Jonathan Walz and Hal Rottenberg interview /n software’s Eric Madariaga about NetCmdlets and PowerShellToys (PowerShellASP). My favorite part was when Hal was shocked to hear that a telnet cmdlet was added to the v2 beta. Hahaha. I completely agree – who uses telnet anymore? But that was actually the biggest request we got from people who were using v1 of NetCmdlets! We already had cmdlets for executing commands over ssh…but people really wanted telnet. This ......

Posted On Monday, August 11, 2008 4:57 PM

NetCmdlets SFTP - Public Key Authentication in PowerShell
In the past I gave examples of using the get-ftp and send-ftp cmdlets for PowerShell, but recently a user pointed out that I didn’t show any examples of public key authentication using the cmdlets. Of course the –ssh flag tells the get-ftp and send-ftp cmdlets to use SSH (instead of plain text FTP, or an SSL connection which is turned on with the –ssl flag). For SSH connections, the AuthMode parameter determines what type of SSH authentication to perform – in this case that will be “publickey”. The ......

Posted On Wednesday, June 25, 2008 10:29 AM

Free NetCmdlets license
/n software's NetCmdlets is available for free for non-commercial use. Check out the NetCmdlets hobbyist license here. Update! The ordering process does not require a credit card unless you request a physical cd shipment. For electronic download, just be sure to enter your name and email address! Technorati Tags: NetCmdlets, PowerShell ......

Posted On Tuesday, January 15, 2008 3:17 PM

NetCmdlets Cheat Sheet (PowerShell)
Last winter, Ben Pearce put together a little PowerShell Cheat Sheet. I printed it out and I keep it handy at my desk. It occurred to me that a NetCmdlets cheat sheet would be useful too, so I borrwed Ben's style and did just that. NetCmdlets Cheat Sheet - .docxNetCmdlets Cheat Sheet - .doc If you see something missing or if there are mistakes, let me know and I will update here. Technorati Tags: PowerShell, NetCmdlets ......

Posted On Friday, August 31, 2007 6:09 PM

LDAP PowerShell User Account Control
The userAccountControl attribute is used to control the access of a user account. This value can be set to the bitwise OR of a set of flag values, documented here: Property flag Value in hexadecimal Value in decimal SCRIPT 0x0001 1 ACCOUNTDISABLE 0x0002 2 HOMEDIR_REQUIRED 0x0008 8 LOCKOUT 0x0010 16 PASSWD_NOTREQD 0x0020 32 PASSWD_CANT_CHANGE Note You cannot assign this permission by directly modifying the UserAccountControl attribute. For information about how to set the permission programmatically, ......

Posted On Wednesday, August 22, 2007 1:22 PM

LDAP PowerShell - Search for Disabled User Accounts
PS C:\> get-ldap -server testboy -cred $mycred -dn dc=JUNGLE -searchscope wholesubtree -search "(&(objectclass=user)(o... Again, there's no need for dozens of LDAP cmdlets. The two LDAP cmdlets included in NetCmdlets, get-ldap and set-ldap, are all you need for most tasks. The above command shows how you would search for disabled user accounts with the get-ldap cmdlet. Technorati Tags: PowerShell, LDAP, Active directory, ......

Posted On Tuesday, August 14, 2007 10:51 AM

LDAP - Change Group Membership
In my previous posts about LDAP group membership, I've talked about how to get a list of groups, how to search for a particular groups members, and how to search for what groups a particular user belongs to. Up next: how to change group membership. To add or remove a user from a group, you need to modify the "member" attribute of the group itself. To do this we'll use the set-ldap cmdlet of NetCmdlets. Add a user to a group: To add a user to a group, set the DN parameter of set-ldap to the DN of ......

Posted On Monday, August 6, 2007 10:22 AM

LDAP - Search for What Groups a Particular User Belongs to
In the last LDAP series post, I mentioned how to search for the members of a group. Now the opposite, here's how to search for what groups a particular user is a part of: To do this search, all I do is form a search filter that is searching for all groups that has a particular member in it. So really this is a slight alteration of the search for all groups. PS C:\> get-ldap -server testboy -cred $mycred -dn dc=JUNGLE -searchscope wholesubtree -search "(&(member=CN=Lance Robinson,CN=Users,DC=JUNGLE... ......

Posted On Friday, August 3, 2007 12:51 PM

LDAP - Search for Group Members
More with the ldap cmdlets in NetCmdlets, here's how to list the members of a particular group. I used the get-ldap command shown in the last post to get a list of all my admin groups, and save it in a $groups collection: PS C:\> $groups = get-ldap -server myserver -cred $mycred -dn dc=JUNGLE -searchscope wholesubtree -search "(&(objectclass=group)(... PS C:\> $groups Host DN ---- -- testboy CN=Administrators,CN=Builti... testboy CN=Schema Admins,CN=Users,DC=JUNGLE testboy ......

Posted On Thursday, August 2, 2007 9:31 AM

LDAP - Search for Active Directory Groups in PowerShell
NetCmdlets doesn't have a long list of Active Directory cmdlets for PowerShell. Instead, it has 2. And they aren't AD specific - they just implement the LDAP protocol itself so they can work with any LDAP server, Active Directory or not. Two cmdlets are all that is needed to make common tasks simple. One for setting values (set-ldap), and one for getting values (get-ldap). Here's how I can retrieve a list of all the "admin" groups: PS C:\> get-ldap -server myserver -cred $mycred -dn dc=JUNGLE ......

Posted On Wednesday, August 1, 2007 10:28 AM

Impressions from TechEd 2007
Dale Churchward is impressed by NetCmdlets, which he found after David Aiken posted about the NetCmdlets stickers being given away at TechEd. Harry Pierson liked the PowerShell skinned XBox that /n software had at the NetCmdlets booth. Did you get your PowerShell sticker yet and enter the drawing for the XBox? If not, do it now! Jeffrey Snover keeps on doing "snoopy dances" about PowerShell. Who can blame him ......

Posted On Friday, June 8, 2007 3:44 PM

PowerShell Secure Remoting
You have to love this awesome introduction to NetCmdlets: My previous, scathing, blood-drawing, bruise-inflaming, vein-popping critique of the lack of SSH awareness in the Port25 show has lead my hate-filled, black heart to NetCmdlets by nsoftware.com. Just hilarious. Hopefully NetCmdlets lightened his heart a bit. Also, as I mentioned in the last post, note that /n software's new PowerShell Remoting (beta) was just made available. The PowerShell Remoting server (SSH terminal service) allows interaction ......

Posted On Wednesday, June 6, 2007 1:08 PM

PowerShelling from mobile devices
Marco Shaw is PowerShelling from his blackberry by running /n software's new PowerShell Remoting server along with the "Mobile SSH" client application for wireless handhelds . You can connect to the PowerShell Remoting client using any SSH tool, or even create your own custom client using a developer tool like IP*Works! S/Shell development toolkit. Technorati : Netcmdlets, PowerShell, nsoftware, ssh ......

Posted On Wednesday, June 6, 2007 12:58 PM

NetCmdlets Command Line Emailer saves ME time
Scott Hanselman has a little TODO batch file that he uses to quickly email himself notes from the command line. I have something similar, but mine is a PowerShell script that uses NetCmdlets. The cool thing about the send-email cmdlet in NetCmdlets is that it supports SSL as well as other email features like html mail and attachments. There are separate cmdlets for sending other types of messages like Usenet newsgroup articles, Jabber IMs (ie, Google Talk), SMS messages, SNMP traps, etc. Here is ......

Posted On Wednesday, February 28, 2007 9:04 AM

PowerShell cmdlet for SNMP (part 2: sysUpTime)
Brandon updated his get-uptime script to output a custom object. Brandon's script works with the LastBootUpTime property returned from WMI Win32_OperatingSytem. I already talked briefly about the get-snmp, set-snmp, get-trap, and send-trap cmdlets that are included in NetCmdlets. Here's how you can use get-snmp to get the sysUpTime from any SNMP-enabled device. Note: sysUpTime is defined as the time since the last re-initialization (ie, boot) of the device, in 100ths of a second. get-snmp -agent ......

Posted On Tuesday, February 27, 2007 3:26 PM

Using PSCredentials without a prompt
You cannot use get-credential without some type of prompt (although you can do it without the pop-up dialog), however you can save your securestring password to a file, reload it for later, and manually create a credential without a prompt. Of course the problem with this is that your password will be exposed to anyone with access to the file, so do this at your own risk. First, choose your password and write it to a file: PS C:\> read-host -assecurestring | convertfrom-securestring | out-file ......

Posted On Friday, February 16, 2007 1:21 PM

PowerShell remote exec and secure shell
This is not a post about .Net remoting. And its not a post about accessing PowerShell through ssh. Here I'm talking about sending remote executions through rexec, rshell, and secure shell connections. Rexec and Rshell (rsh.exe) already exist as command line applications, but they do not exists in the PowerShell world (that is, they do not return objects). NetCmdlets send-rexec and send-rshell cmdlets take care of this problem. Each remote execution returns a collection of objects that contain the ......

Posted On Wednesday, January 24, 2007 1:46 PM

Change Active Directory password with NetCmdlets
Here's how you can change your active directory (or other ldap server) password with the set-ldap cmdlet in /n software NetCmdlets. Also, recently I also showed how to this using the IP*Works! SSL LdapS dev component. PS C:\> set-ldap -server myserver -binddn Domain\Administrator -password admin -dn "cn=BillyBob,ou=Employees,d... -newpassword mynewpassword -ssl implicit Update: the -password parameter is now a secure string. There is also a -credential parameter. So the cmd to change the ......

Posted On Wednesday, December 27, 2006 1:33 PM

NetCmdlets support PSCredentials
Previously with NetCmdlets, authentication details were only accepted using plain text parameters. This is still supported, but now these cmdlets support PSCredentials through a new -credentials parameter. This works for almost all of the cmdlets included in NetCmdlets, like FTP, LDAP, HTTP, SMTP, Rexec, RSS, IM, SMS, SSH, etc. Here's an example with get-ldap. Before, you had to bind to the directory server using plain text parameters, like this: PS C:\> get-ldap -server testboy -binddn mydomain\admin ......

Posted On Wednesday, December 27, 2006 1:27 PM

NetCmdlets Part 3: PowerShell and Active Directory using /n software's LDAP cmdlet
MOW's "PowerShelled" blog is another awesome PowerShell resource. Of particular interest to me was MOWs series on PowerShell and Active Directory. He used the .Net System.DirectoryServices classes to do all the work. here is how you can use /n software's LDAP cmdlet to manage directory servers like AD. The LDAP cmdlet supports plain connections as well as secure SSL connections. The LDAP cmdlet will work with any directory server, including AD, ADAM, OpenLDAP, Novell, etc. The LDAP cmdlet uses its ......

Posted On Wednesday, December 27, 2006 1:25 PM

NetCmdlets FTP - recursive directory upload
update: here's an updated function for uploading an entire directory tree: ## ftprecursiveupload.ps1: Recursive FTP Upload## Uploads a directory tree to a remote FTP server.## Returns an objects containing information about the files transferred.function upload-directory { param( [string] $server = $( Throw "You must specify an FTP server to logon to."), [string] $dir = $( Throw "You must specify a local directory to upload (ie, C:\Testing\FTPTest\)"), [switch] $overwrite = $false, [System.Management.Automati... ......

Posted On Thursday, December 7, 2006 11:37 AM

Vivek's out-ie and out-html scripts, Netcmdlets convert-data cmdlet
I found Vivek Sharma's blog through Jeffrey Snover on the MS PowerShell blog. He's got some good geeky stuff there, including some useful PowerShell posts. Vivek's out-ie is useful, so I snagged that for myself. I tried to create an out-ff but I hit a stumbling block because the Mozilla ActiveX Control requires a control container. out-html is not so useful because convertto-html already comes with powershell. NetCmdlets now includes a convert-data cmdlet which converts data to and from many different ......

Posted On Wednesday, November 29, 2006 2:59 PM

PowerShell 1.0 Released
PowerShell 1.0 was released yesterday in Spain, and /n software was there! When you go to download it (for free), don't forget to pickup NetCmdlets too. Also check out Jeffrey Snover's 12 Cool Features of Windows PowerShell. You'll need to uninstall previous versions of PowerShell before you can install the new one, but PowerShell won't appear in Add/Remove Programs unless you check the "show updates" box. Technorati : cmdlets, netcmdlets, powershell ......

Posted On Wednesday, November 15, 2006 10:34 AM

NetCmdlets Part 2: PowerShell cmdlet for SNMP (network management)
The SNMP PowerShell cmdlets that come with /n software NetCmdlets support SNMP v1, v2c, and v3, SNMPv3 auth/priv, MIB loading, etc. Here are some examples of using the Get-SNMP, Set-SNMP, Send-Trap, and Get-Trap cmdlets. Find SNMP enabled machines (agents) on your network:PS C:\> get-snmp -agent 255.255.255.255 -oid sysName.0 Find processes running on a remote snmp-enabled machine:PS C:\> get-snmp -agent myagent -oid hrSWRunName -walk $true Send an SNMP trap to a remote manager:PS C:\> send-trap ......

Posted On Thursday, November 9, 2006 12:10 PM

NetCmdlets Part 1: PowerShell cmdlet for FTP (plus FTPS and SFTP)
Some examples of using NetCmdlets in PowerShell. The FTP NetCmdlet supports plain and secure (both SSL and SSH) FTP connections right from the PowerShell console. List files on a remote server: PS C:\> get-ftp -server myserver -user lancer -password mypass The same, but using SSL (auth-tls): PS C:\> get-ftp -server myserver -user lancer -password mypass -ssl explicit And again, but using SSH 2.0: PS C:\> get-ftp -server myserver -user lancer -password mypass -ssh Find the files on a remote ......

Posted On Thursday, November 9, 2006 11:37 AM

Copyright © Lance Robinson | Powered by: GeeksWithBlogs.net