Wlan Import ps1

Author Message
gdewrance

  • Total Posts : 591
  • Scores: 3
  • Reward points : 0
  • Joined: 3/16/2006
  • Status: offline
Wlan Import ps1 Thursday, June 02, 2011 8:53 PM (permalink)
0
I have a directory and exported all wlan's to .xml and at the moment import via .bat file, how do I get them to import using the following script
Please can someone help me out here Where in this script do I show the directory holding the .xml files that need to be imported.
I don't need the export part just need the import part. [That's why I commented it out]
 
<# 
 
 NAME: WLAN-functions.ps1 
 
 AUTHOR: Jan Egil Ring 
 EMAIL: jan.egil.ring@powershell.no 
 
 COMMENT: PowerShell functions to export and import WLAN profiles in Windows Vista/Windows 7 
 
 Required version: Windows PowerShell 2.0 (built-in to Windows 7) 
 Usage: Either copy the functions directly into a PowerShell session, or dot-source the script 
 to make the functions available (. .\WLAN-functions.ps1) 
 
 For more information, see the following blog-post: 
 http://blog.powershell.no/2011/01/23/export-and-import-wlan-profiles 
 
 You have a royalty-free right to use, modify, reproduce, and 
 distribute this script file in any way you find useful, provided that 
 you agree that the creator, owner above has no warranty, obligations, 
 or liability for such use. 
 
 VERSION HISTORY: 
 1.0 23.01.2011 - Initial release 
 
#> 
<#
function Export-WLAN { 
 
.SYNOPSIS 
Exports all-user WLAN profiles 
.DESCRIPTION 
Exports all-user WLAN profiles to Xml-files to the specified directory using netsh.exe 
.PARAMETER XmlDirectory 
Directory to export Xml configuration-files to 
.EXAMPLE 
Export-WLAN -XmlDirectory c:\temp\wlan 
 
 
[CmdletBinding()] 
 param ( 
 [parameter(Mandatory=$true)] 
 [string]$XmlDirectory 
 ) 
 
#Export all WLAN profiles to specified directory 
$wlans = netsh wlan show profiles | Select-String -Pattern "All User Profile" | Foreach-Object {$_.ToString()} 
$exportdata = $wlans | Foreach-Object {$_.Replace("    All User Profile     : ",$null)} 
$exportdata | ForEach-Object {netsh wlan export profile $_ $XmlDirectory key=clear} 
} 
#>
function Import-WLAN { 
<# 
.SYNOPSIS 
Imports all-user WLAN profiles based on Xml-files in the specified directory 
.DESCRIPTION 
Imports all-user WLAN profiles based on Xml-files in the specified directory using netsh.exe 
.PARAMETER XmlDirectory 
Directory to import Xml configuration-files from 
.EXAMPLE 
Import-WLAN -XmlDirectory c:\temp\wlan 
#> 
 
[CmdletBinding()] 
 param ( 
 [parameter(Mandatory=$true)] 
 [string]$XmlDirectory 
 ) 
 
#Import all WLAN Xml-files from specified directory 
Get-ChildItem $XmlDirectory | Where-Object {$_.extension -eq ".xml"} | ForEach-Object {netsh wlan add profile filename=($XmlDirectory+"\"+$_.name)} 
}

 

"You start coding. I'll go find out what they want."
 
#1
    gdewrance

    • Total Posts : 591
    • Scores: 3
    • Reward points : 0
    • Joined: 3/16/2006
    • Status: offline
    Re:Wlan Import ps1 Friday, June 03, 2011 1:27 AM (permalink)
    0
    If I run the code below it imports the xml files.
     
     $XmlDirectory='\\server\share\wireless'
    #Import all WLAN Xml-files from specified directory 
    Get-ChildItem $XmlDirectory | Where-Object {$_.extension -eq ".xml"} | ForEach-Object {netsh wlan add profile filename=($XmlDirectory+"\"+$_.name)} 

     
     
    Now how do I add all of the following
     netsh wlan add  filter permission=block ssid="SomeSSID" networktype=infrastructure
     netsh wlan add filter permission=block ssid="SomeSSID"  networktype=infrastructure
     netsh wlan add filter permission=block ssid="SomeSSID"  networktype=infrastructure 


    "You start coding. I'll go find out what they want."
     
    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • New Messages
      • No New Messages
      • Hot Topic w/ New Messages
      • Hot Topic w/o New Messages
      • Locked w/ New Messages
      • Locked w/o New Messages
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.9