Powershell Script Error, its saying The term is not recognized as the name of cmdlet

Hi,
When i am running following script into powershell, getting this error. i was not able to find out what could be the cause?Please
help me out.
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
functionCreate-SPFoldersBulk
    Param
           [parameter(Mandatory=$true)][string]$SiteUrl,
           [parameter(Mandatory=$true)][string]$LibraryName,
           [parameter(Mandatory=$true)][string]$CSVPath
    # Import CSV
    [array]$FolderList
= Import-Csv
$CSVPath
    # Script Variables
    $spWeb
= Get-SPWeb
$SiteUrl
    $spList
= $spWeb.Lists[$LibraryName]
    Foreach
($folderGroup
in
$FolderList) {
        # Create Parent Folder
        $parentFolder
= $spList.Folders.Add("",[Microsoft.SharePoint.SPFileSystemObjectType]::Folder,$folderGroup.Root)
        $parentFolder.Update()
        Write-Host "The Parent folder" $folderGroup.Root "was
successfully created" -foregroundcolor Green
        # Loop variables
        $i = 1
        $col = "S"
        $colID = $col + $i
        While ($folderGroup.$colID -ne $null)
            $newSubfolder = $splist.Folders.Add($parentFolder.Folder.ServerRelativeUrl,
[Microsoft.SharePoint.SPFileSystemObjectType]::Folder,$folderGroup.$colID)
            $newSubfolder.Update()
            Write-Host "The subfolder" $folderGroup.$ColID
"was successfully created"
-foregroundcolor
Cyan
            $i++
            $colID
= $col
+ $i
    $spWeb.Dispose()

Well assuming that is the entirety of your Create-SPFoldersBulk.ps1 script then the first issue is that it does currently do anything. Your script defines a function but then doesn't call it.
You're then running the script correctly as :
.\Create-SPFoldersBulk.ps1
and then I'm guessing you're trying to run the function, but that won't work from a command line. That's why you're getting the error, PowerShell doesn't know about the function outside of the code execution, and won't run the script instead since you haven't
added .\ before it.
If you really want it to be using a function then you'll need code later in the script to call that function, eg add the function call you entered at the prompt into the script at the bottom, and then run the script like you did initially, or if you're looking
to be able to run the script and be able to pass those parameters to it from the prompt then you probably want to adjust the script to :
Param (
[parameter(Mandatory=$true)][string]$SiteUrl,
[parameter(Mandatory=$true)][string]$LibraryName,
[parameter(Mandatory=$true)][string]$CSVPath
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
# Import CSV
[array]$FolderList = Import-Csv $CSVPath
# Script Variables
$spWeb = Get-SPWeb $SiteUrl
$spList = $spWeb.Lists[$LibraryName]
Foreach ($folderGroup in $FolderList) {
# Create Parent Folder
$parentFolder = $spList.Folders.Add("",[Microsoft.SharePoint.SPFileSystemObjectType]::Folder,$folderGroup.Root)
$parentFolder.Update()
Write-Host "The Parent folder" $folderGroup.Root "was successfully created" -foregroundcolor Green
# Loop variables
$i = 1
$col = "S"
$colID = $col + $i
While ($folderGroup.$colID -ne $null)
$newSubfolder = $splist.Folders.Add($parentFolder.Folder.ServerRelativeUrl, [Microsoft.SharePoint.SPFileSystemObjectType]::Folder,$folderGroup.$colID)
$newSubfolder.Update()
Write-Host "The subfolder" $folderGroup.$ColID "was successfully created" -foregroundcolor Cyan
$i++
$colID = $col + $i
$spWeb.Dispose()
and then call the script from the prompt as :
.\Create-SPFoldersBulk.ps1 -SiteUrl "https://spdev.baordbooks.com/legal/DAP/" -LibraryName "DAP Documents" -CSVPath "C:\Script_Files\folderList.csv"

Similar Messages

  • Can iMessage be used with non iOS 5 users, ie non-apple users. My new i-pad 2 error message says these contacts are not recognized by imessage when I try to text some of these contacts.

    Can iMessage be used with non iOS 5 users, ie non-apple users?
    My new i-pad 2 error message says these contacts are not recognized by imessage when I try to send them a text.

    So that means that I can send text messages through my i-phone to reach non iOS 5 users, but not through my i-pad 2.

  • HT201210 my iphone 3 couldn't restore, its saying the error 46. what is the meaning of error 46?and how can i resolve it?

    my iphone 3 couldn't restore, its saying the error 46. what is the meaning of error 46?and how can i resolve it?

    It doesn't matter when you installed antivirus software; if you have it on your computer it will frequently block access from applications to sites it does not know about. A sync does not require access to a site not on your computer; an upgrade clearly does. So if you have never jailbroken any device you do not need to be concerned about your hosts file, but you DO need to temporarily disable your antivirus during the update process.
    The hosts file is an operating system file on all computers that overrides DNS lookup. In order to jailbreak or hack an iDevice the programs that do it need to redirect iTunes so it does not go to the Apple activation server, but instead goes to the hacking program for activation instructions. It does this by adding a record to the hosts file that bypasses the DNS lookup for gs.apple.com. But you don't have to be concerned about this.

  • Term is not recognized when executing PowerShell Script through SQL Agent using CMDEXEC

    I am trying to simply execute a PowerShell script that is stored in a file on a network drive through SQL Agent as a job. The script is a basic copy from one directory to another.  I have run and successfully executed this from a command prompt outside
    of SQL Agent.  When I execute this through SQL Agent as a Operating System (CmdExec) command I am getting an error that the term is not recognized as the name of a cmdleet, function, script file or operable program. I have executed many different ways
    put found an article to use double quotes in the network path which I have done with no success. 
    I am executing the following command as a job in SQL Agent:
    PowerShell H:\"\PowerShell""\PS_Scripts\"\batchcopyFFLWithProgress.ps1 through SQL Agent job
    I get the following error message:
     04/21/2015 10:01:09,Copy FFL Files,Error,1,NY11266-LTW7E\JPLAPTOPSQL,Copy FFL Files,Copy FFL files,,Executed as user: NT Service\SQLAgent$JPLAPTOPSQL. H:\PowerShell\PS_Scripts\batchcopyFFLWithProgress.ps1 : The term   'H:\PowerShell\PS_Scripts\batchcopyFFLWithProgress.ps1'
    is not recognized as   the name of a cmdlet<c/> function<c/> script file<c/> or operable program. Check the   spelling of the name<c/> or if a path was included<c/> verify that the path is   correct and try again.
     At line:1 char:1  + H:"\PowerShell\PS_Scripts"\batchcopyFFLWithProgress.ps1  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~      + CategoryInfo          : ObjectNotFound:
    (H:\PowerShell\P...ithProgress.p      s1:String) []<c/> CommandNotFoundException      + FullyQualifiedErrorId : CommandNotFoundException.  Process Exit Code 1.  The step failed.,00:00:03,0,0,,,,0
    Content of batchcopyFFLWithProgress.ps1 which has the PowerShell script:
    $source=ls H:\SQLTest\Script\TestData\*.*
    $i=1
    $source| %{
        [int]$percent = $i / $source.count * 100
        Write-Progress -Activity "Copying ... ($percent %)" -status $_ -PercentComplete $percent -verbose
        copy $_.fullName -Destination H:\test -Recurse
        $i++
    I have searched the internet and have not found any resolution to my error.  If someone has experienced this error and found the resolution I would greatly appreciate your help.

    I have change the service account for SQL Agent to be my domain account as I have local admin rights to my laptop.  I stopped and started the services for SQL Agent and than started the job to run which is copying locally to minimize any network drive
    issues.  I am still getting the same error message as it is showing that I am executing the job under my domain account?  Any thoughts what it could be?
    ErrorMsg
    04/23/2015 11:21:06,Copy FFL Files,Error,1,ServerName\InstanceName,Copy FFL Files,Copy FFL files,,Executed as user: Domain\DomainAccount. \\ServerName\Test\PS_Script\batchcopyFFLWithProgress.ps1 : The term '\\ServerName\Test\PS_Script\batchcopyFFLWithProgress.ps1'
    is   not recognized as the name of a cmdlet<c/> function<c/> script file<c/> or operable program. Check the spelling of the name<c/> or if a path was   included<c/> verify that the path is correct and try again.  At
    line:1 char:1  + \\ServerName\Test\PS_Script\batchcopyFFLWithProgress.ps1  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~      + CategoryInfo          : ObjectNotFound: (\\ServerName...ithProgress.ps1:String)
    []<c/> CommandNotFoundException      + FullyQualifiedErrorId : CommandNotFoundException.  Process Exit Code 1.  The step failed.,00:00:02,0,0,,,,0
    Script
    $source=ls "\\ServerName\Test\TestData\*.*"
    $i=1
    $source| %{
        [int]$percent = $i / $source.count * 100
        Write-Progress -Activity "Copying ... ($percent %)" -status $_ -PercentComplete $percent -verbose
        copy $_.fullName -Destination "\\ServerName\Test\test" -Recurse
        $i++

  • I have two versions of Pr, one is the latest 2014 and when trying to open a Pr2014 session, I get an error message saying the project was saved in a newer version and cannot be opened. Help

    I have two versions of Pr, one is the latest 2014 and when trying to open a Pr2014 session, I get an error message saying the project was saved in a newer version and cannot be opened. Could there be an issue with an older Pr application on the computer? Please help!

    You need to be very careful which project you open in which version.
    For 2014 make sure its on 2014.1 build 81.

  • When I click on firefox I get a java script error that says "TypeError: Components.classes[TvtPwmComponent_CID] is undefined", what does that mean?

    Whenever I click on firefox, or when a pop-up occurs, I get a java script error that says, "TypeError: Components.classes[TvtPwmComponent_CID] is undefined". I don't know why. It first occurred while I was on ESPN while trying to watch college games live.

    This issue can be caused by an extension that isn't working properly.
    *https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode

  • When trying to restore and update my ipod touch it comes up with an error message saying: "The ipod can not be restored this device isnt eligible for the requested build"

    When trying to restore and update my ipod touch it comes up with an error message saying: "The ipod can not be restored this device isnt eligible for the requested build" How do i fix this?

    I am having the same issue. I just had the battery replaced at a third party store. The battery powers the ipod up but it needs to be restored. It is saying it isn't eligible for rebuild. I am running MAC OS 10.4.11  itunes v. 9.0   and I just want it to be restored. I need help.  Oh and its an 8 gb ipod touch.

  • How do I view and open all my files again that are on my external hard drive?? Error message saying 'The disk you inserted was not readable by this computer' Three options are Initialize, Ignore or Eject.

    I have recently purchased Toshiba 1TB hard drive and I set it up and I was able to transfer all my files onto it such as my music, photos, documents. I had correctly ejected and used it again and all these files were safely stored and accessible afterwards. However after I rebooted my computer as it had been going slow and I had too much clogging it up once I reconnected the external hard drive I have error message saying 'The disk you inserted was not readable by this computer' Three options are Initialize, Ignore or Eject. How do I access all my files? I set it up to work on both mac and windows. I have tried both another mac and windows computer and same issue occurs?? I am worried that all my personal files are gone but am confused as the drive has had absolutely no damage to it as it was in a very short time frame and its never left the same spot. Any help would be greatly appreciated. Thanks

    Thanks for your quick response. I had a look at your discussion... I tried it on a Windows machine and I thought that was compatible with ExFAT?
    Therefore I need to attempt to use my external hard drive with a machine that boasts OS X 10.6.5 or above and then it should work?
    Thanks

  • Just wanted to make sure I had the most up to date version of ITunes on my desktop first.  Tried to get on site, and got an error message saying; The folder ITunes is on a locked disk or you do not have write permissions for this folder.  Help!

    Wanted to sync up my new IPhone4, and thought that I should make sure I had the most up to date version of ITunes on my desktop first.  Tried to get on site, and got an error message saying; "The folder ITunes is on a locked disk or you do not have write permissions for this folder."   Cannot get on ITunes at all now.  Help!  Thx.

    In my case its a new computer the old one was stolen and the time machine disk did not work for a restore but did for copying the info to the new mac

  • Script error line 2053 the specified module could not be found URL res://ieframe.dll/preview.js

    Script error line 2053 the specified module could not be found URL res://ieframe.dll/preview.js

    The issue is caused when Windows creates the printer profile in the control panel that it doesn't correctly create it with the drivers.
    We're not going to completely uninstall all the HP software, instead we're going to remove the corrupt Windows printer profile and reinstall it.  Total time for this on an average computer is about 5-10 minutes to completely repair (including reboot).
    1) Navigate to Start Menu > Devices and Printers or Start Menu > Control Panel > Printers
    2) Select each printer profile for the printer with an issue, then select remove device/printer.
    3) Reboot
    4) Navigate to Start Menu > All Programs > HP > insert model # here > Add Printer (or Setup Wizard)
    5) Follow the setup prompts to reinstall the printer profile and it recreates the Windows printer.
    6) Run the HP Update Tool from Start Menu > All Programs > HP if your printer installs it, rebooting afterwards if necessary.
    7) Test by printing google.com (uses very little ink when the test page comes out).
    Let me know if you have any questions or issues.
    Thanks,
    Dan
    I work for an internation tech company and personally perform thousands of computer repairs a year. I'm based out of the US working for a US company, and have been working on computers for over 13 years.
    ****Click the White Kudos star to say thanks****
    ****Please mark Accept As Solution if it solves your problem****

  • TS1424 I get an error message saying "the iTunes Library cannot be saved. An unknown error occurred (-50)

    I get an error message saying “the iTunes Library cannot be saved. An unknown error occurred (-50) How can I fix it?

    You need to be very careful which project you open in which version.
    For 2014 make sure its on 2014.1 build 81.

  • I have an older iMAC that once burned CD's with no issues. Now I get an error message saying "The attempt to burn a disc failed. The device is not accessible, probably because it was removed". I have never had it touched so the device was not removed.Help

    I have an olde iMac that once I have an older iMAC that once burned CD's with no issues. Now I get an error message saying "The attempt to burn a disc failed. The device is not accessible, probably because it was removed". I have never had it touched so the device was not removed. Please advise as to what could be the problem. How to fix. Thanks

    Try resetting the SMC and PRAM first, if that doesn't help try a cleaning disc.....and then buy an inexpensive external burner. Slimline super drive failures are all too common.
    To reset the SMC
    Shut down the computer.
    Unplug the computer's power cord.
    Wait fifteen seconds.
    Attach the computer's power cord.
    Wait five seconds, then press the power button to turn on the computer.
    Resetting NVRAM / PRAM
    Shut down your Mac.
    Locate the following keys on the keyboard: Command (⌘), Option, P, and R. You will need to hold these keys down simultaneously in step 4.
    Turn on the computer.
    Press and hold the Command-Option-P-R keys before the gray screen appears.
    Hold the keys down until the computer restarts and you hear the startup sound for the second time.
    Release the keys.

  • Trying to download iTunes 11.1 but it keeps giving me an error message saying: The feature you are trying to use is on a network resource that is unavailable.

    Trying to download iTunes 11.1 but it keeps giving me an error message saying:
    The feature you are trying to use is on a network resource that is unavailable.
    Click OK to try again, or enter an alternate path to a folder containing the installation package "iTunes64.msi" in the box below.
    Use Source:

    iTunes.msi
    Perfect, thanks.
    Download the Windows Installer CleanUp utility from the following page (use one of the links under the "DOWNLOAD LOCATIONS" thingy on the Major Geeks page):
    http://majorgeeks.com/download.php?det=4459
    To install the utility, doubleclick the msicuu2.exe file you downloaded.
    Now run the utility ("Start > All Programs > Windows Install Clean Up"). In the list of programs that appears in CleanUp, select any iTunes entries and click "Remove", as per the following screenshot:
    Quit out of CleanUp, restart the PC and try another iTunes install. Does it go through properly this time?

  • HT1926 I have just updated itunes on my pc (widows XP) to the latest version. When I try to open it i get an error message saying the application failed to start because MSVCR80.dll could not be found. Not sure how to resolve this. Have tried to reinstall

    I have just updated itunes on my pc (windows XP) to the latest version. When I try to open it I get an error message saying the application failed to start because MSVCR80.dll was not found< Have tried reinstalling with no luck. Any ideas?

    try removing all itunes and all other apple program
    follow this link for more info. http://support.apple.com/kb/HT1923
    reboot ur window after uninstalling
    after that download the latest itunes setup and install.

  • All of a sudden I'm getting a 'itunes.exe - system error  It says the program can't start because MSVCR80.dll is missing from your computer.  Try reinstalling the program to fix this problem.  I have tried to reinstall and still can't open itunes.  help!

    all of a sudden I'm getting a 'itunes.exe - system error  It says the program can't start because MSVCR80.dll is missing from your computer.  Try reinstalling the program to fix this problem.  I have tried to reinstall and still can't open itunes.  help!

    Try the following user tip:
    Troubleshooting issues with iTunes for Windows updates

Maybe you are looking for