Howto create a powershell script to search the C drive for any *.pst files and copy them to a single directory

I have a bunch of people who are saving their pst files all over the place. how do I write a script that does the following
searches the C:\ drive for *.pst and copies them all the E:\pstfiles

Hi,
How about using below command:
Move-Item c:\*.pst E:\pstfiles -force
For more details about move-item, I would like suggest you use get-help command:
get-help move-item
In addition:
Using the Move-Item Cmdlet
http://technet.microsoft.com/en-us/library/ee176910.aspx
Regards,
Yan Li
Yan Li
TechNet Community Support

Similar Messages

  • Powershell script to search a network drive for .mdb files and export them to CSV file

    Hello all,
    I'm trying to search one of our network drives for old .mdb files, I want to write the name, location and date last modified to a csv file.
    Get-WmiObject -Class CIM_DataFile -Filter "Drive='S:' And Extension='mdb'
     AND ObjFile.drive
     AND objFile.FileName
     AND objFile.FileSize
     AND objFile.LastWriteTime" |
    Export-CSV c:\mdb_search\mdbfiles.csv\
    Obviously this isn't working or I wouldn't be posting.  I've tried many different examples from the net with no joy for now.
    Thanks for any help you can offer.

    Thanks, that did the job.
    Cheers, you're welcome.
    How do I get the powershell cursor to return to C:> ?
    Should I use "exit" or "break" ?
    Neither, the console will return to a prompt when the search has been completed.
    Don't retire TechNet! -
    (Don't give up yet - 13,225+ strong and growing)

  • PowerShell Script to get the details Like Scope,Last Deployed date and Name for a Solution Deployed in the Farm.

    Hi Experts,
    I am trying to  build a PowerShell Script to get the details Like Scope,Last Deployed date and Name for a Solution Deployed in the Farm.
    Can anyone advise on this please.
    Regards

    Get-SPSolution|Select Name,Scope,LastOperationResult,LastOperationEndTime|Export-CSV "SPInstalledSolutions.csv" -NoTypeInformation
    SPSolution properties
    Get-SPSolution
    This post is my own opinion and does not necessarily reflect the opinion or view of Slalom.

  • SharePoint PPS 2013 Dashboard Designer error "Please check the data source for any unsaved changes and click on Test Data Source button"

    Hi,
    I am getting below error in SharePoint PPS 2013 Dashboard Designer. While create the Analysis Service by using "PROVIDER="MSOLAP";DATA SOURCE="http://testpivot2013:9090/Source%20Documents/TestSSource.xlsx"
    "An error occurred connecting to this data source. Please check the data source for any unsaved changes and click on Test Data Source button to confirm connection to the data source. "
    I have checked all the Sites and done all the steps also. But still getting the error.Its frustrating like anything. Everything is configured correctly but still getting this error.
    Thanks in advance.
    Poomani Sankaran

    Hi Poomani,
    Thanks for posting your issue,
    you must have to Install SQL Server 2012 ADOMD.Net  on your machine and find the browse the below mentioned URL to create SharePoint Dashboard with Analysis service step by step.
    http://www.c-sharpcorner.com/UploadFile/a9d961/create-an-analysis-service-data-source-connection-using-shar/
    I hope this is helpful to you, mark it as Helpful.
    If this works, Please mark it as Answered.
    Regards,
    Dharmendra Singh (MCPD-EA | MCTS)
    Blog : http://sharepoint-community.net/profile/DharmendraSingh

  • I just replaced the hard drive for my Mac Pro, and I am trying to restore what is on my Time Capsule, but it wont connect, and only is giving me the pinwheel of death. What do i do?

    I just replaced the hard drive for my Mac Pro, and I am trying to restore what is on my Time Capsule, but it wont connect, and only is giving me the pinwheel of death. What do i do?

    You will need to boot from some alternate boot device to accomplish this, if you did not initialize the drive before installing it.
    If you have another Mac, you may be able to use FireWire target disk mode.
    If your MacBook has a DVD reader and you have a Mac OS X Installer/Utilities DVD, such as the one that shipped with it, you can boot from that DVD, answer only the "what Language" question, and wait a quarter minute for the MenuBar to be drawn. Then examine the Utilities menu or the Installer menu and Find Disk Utility.

  • Powershell Script to change the target destination on a shortcut file.

    Hi All,
    I am in a middle of a new file server implementation and have come across a problem where the items on the old file server has been archived and moved to another server and in place a shortcut is left at the original location. The current target of those
    shortcut is going to be changed and thus I need to change the Target destination on those various shortcuts files. I am new to powershell and will really appreciate if someone can assist me with a powershell script for the below steps:
    To find all shortcut files (Excel, word, powerpoint and other types) whose current target destination is \\abcserver\z\abcpath
    Change the Target destination to \\xyzserver\z\abcpath on the shortcut file and apply the change.
    Effectively only change shortcut files whose current target begins with "\\abcserver\" and change to "\\xyzserver\"
    Search for the next shortcut and continue changing it.
    Hope the above makes sense and appreciate the assistance.
    Thanks!

    Did you look?
    https://www.google.com/?gws_rd=ssl#newwindow=1&q=powershell+change+shortcut+path
    ¯\_(ツ)_/¯

  • What is the best product for converting MTS files (NOT on camera or in root directory) for editing in Final Cut

    Hello all,
    I have read the forums and know that I cannot use the Log and Transfer function on Final Cut Express 4.0 for my AVCHD files (from my Panasonic HC-V700) AFTER I have transfered the files out of the original root directory.  Unfortunately, I did not know this until recently and I have a bunch of old footage in .mts form that I copied onto my harddrive WITHOUT the root directory.  I now must get it into Final Cut Express 4.0.1. and I would like to use a Log and Transfer style program so that I can select what I need and erase the rest.  I know about the program VoltaicHD which can be used for this purpose.  I have not yet purchased it, but I will if this is my best option.  The downsides to it are that it takes a lot of time to process the files (i hear from this forum) and that it creates extremely large files (hearsay from this forum, though I would like to know just how big those files are and how they compare to the size of files final cut creates). When I tried the trial version, I also noticed that unlike the log and transfer function in Final Cut Express 4.0.1, you cannot capture multiple subclips from a single clip.  Well you can, but you have to load the clip into the viewing window again, which is not ideal.
    I would love some more advice on this.  I imagine other people have made this same mistake and have had to figure their way out of it.
    I was also wondering is it possible to use Final Cut Express's Log and Transfer program directly from files if they are in a different file format.  So far my experiments with this have failed.  But if this is possible, I suppose I can also just convert all the backlogged files wholesale into a format that Final Cut Express supports more easily for Log and Transfer (What file format would this be? Sorry I am new to this).  My new harddrive has a lot of free space, so I could probably handle the huge amount of storage that this would require for the raw footage and then I could erase it after I log and transfer just what I need.   In which case, do folks have recommendations for a file convertor.  I am dealing with over hundreds of files and I don't think the free online convertors would work. This product has been suggested to me, but I know very little about it.
    Thanks!
    Mira

    I am also finding, when I use Voltaic trial version, that the quicktime movies it creates are of inferior quality than those created through log and transfer into final cut express and imovie, particularly during rapid movement. There's a lot of visible lines running horizontally around areas of rapid movement (not sure what the lingo is for this).
    Anyway, now I am getting accustomed to the idea that my best bet is probably just a high quality converter to get my mts files into something more useable by final cut.  At this point, I am willing to sit through the render time that it will take on final cut express while I edit.  I am just trying to get my footage into workable format without losing quality.
    Thank you!
    Mira

  • HT4972 My ipad 1 is stuck on IOS 4 as the IOS 5 update instructions do not work. When I use itunes update the software looks for an update file and the apple site doesn't have one!

    My ipad 1 is stuck on IOS 4 as these IOS 5 update instructions do not work. When I use itunes update the software looks for an IOS 5 software update file and the apple site doesn't seem have one anywhere!

    If you have an iPad 1, the max iOS is 5.1.1. For newer iPads, the current iOS is 6.0.1. For the iPad Mini the iOS is 6.0.2. The Settings>General>Software Update only appears if you have iOS 5.0 or higher currently installed.
    iOS 5: Updating your device to iOS 5 or Later
    http://support.apple.com/kb/HT4972
    How to install iOS 6
    http://www.macworld.com/article/2010061/hands-on-with-ios-6-installation.html
    iOS: How to update your iPhone, iPad, or iPod touch
    http://support.apple.com/kb/HT4623
    If you are currently running an iOS lower than 5.0, connect the iPad to the computer, open iTunes. Then select the iPad under the Devices heading on the left, click on the Summary tab and then click on Check for Update.
    Tip - If connected to your computer, you may need to disable your firewall and anitvirus software temporarily.  Then download and install the iOS update. Be sure and backup your iPad before the iOS update. After you update an iPad (except iPad 1) to iOS 6.x, the next update can be installed via wifi (i.e., not connected to your computer).
     Cheers, Tom

  • Powershell script to get the low disk space on the servers...

    Hi,
    We have many SQL & Sharepoint servers running on windows server. I need some Powershell script to get the low disk space on those servers and it should send an mail alert saying "Disc d:\ have less than threshold 15% free space".
    Awaiting for response.
    Thanks
    Anil

    you should be able to use this powershell script which you can run as a scheduled task.
    just change the details at the start of the script to point the script to the right location to create log files. you will need to have a plain text file containing a list of server names or ip addresses that you want to check drive space on.
    # Change the following variables based on your environment
    #specify the path to the file you want to generate containing drive space information
    $html_file_dir = "\\server\share\DriveSpace"
    #specify the path and file name of the text file containing the list of servers names you want to check drive space on - each server name on a seperate line in plain text file
    $server_file = "\\server\share\servers.txt"
    #speicfy the from address for the email
    $from_address = "[email protected]"
    #specify the to address for the email
    $to_address = "[email protected]"
    #specify the smtp server to use to send the email
    $email_gateway = "smtp.domain.com" # Can either be DNS name or IP address to SMTP server
    # The seventh line from the bottom (line 167) is used if your smtp gateway requires authentication. If you require smtp authentication
    # you must uncomment it and set the following variables.
    $smtp_user = ""
    $smtp_pass = ""
    # Change the following variables for the style of the report.
    $background_color = "rgb(140,166,193)" # can be in rgb format (rgb(0,0,0)) or hex format (#FFFFFF)
    $server_name_font = "Arial"
    $server_name_font_size = "20px"
    $server_name_bg_color = "rgb(77,108,145)" # can be in rgb format (rgb(0,0,0)) or hex format (#FFFFFF)
    $heading_font = "Arial"
    $heading_font_size = "14px"
    $heading_name_bg_color = "rgb(95,130,169)" # can be in rgb format (rgb(0,0,0)) or hex format (#FFFFFF)
    $data_font = "Arial"
    $data_font_size = "11px"
    # Colors for space
    $very_low_space = "rgb(255,0,0)" # very low space equals anything in the MB
    $low_space = "rgb(251,251,0)" # low space is less then or equal to 10 GB
    $medium_space = "rgb(249,124,0)" # medium space is less then or equal to 100 GB
    #### NO CHANGES SHOULD BE MADE BELOW UNLESS YOU KNOW WHAT YOU ARE DOING
    # Define some variables
    $ErrorActionPreference = "SilentlyContinue"
    $date = Get-Date -UFormat "%Y%m%d"
    $html_file = New-Item -ItemType File -Path "$html_file_dir\DiskSpace_$date.html" -Force
    # Create the file
    $html_file
    # Function to be used to convert bytes to MB or GB or TB
    Function ConvertBytes {
    param($size)
    If ($size -lt 1MB) {
    $drive_size = $size / 1KB
    $drive_size = [Math]::Round($drive_size, 2)
    [string]$drive_size + ' KB'
    }elseif ($size -lt 1GB){
    $drive_size = $size / 1MB
    $drive_size = [Math]::Round($drive_size, 2)
    [string]$drive_size + ' MB'
    }ElseIf ($size -lt 1TB){
    $drive_size = $size / 1GB
    $drive_size = [Math]::Round($drive_size, 2)
    [string]$drive_size + ' GB'
    }Else{
    $drive_size = $size / 1TB
    $drive_size = [Math]::Round($drive_size, 2)
    [string]$drive_size + ' TB'
    # Create the header and footer contents of the html page for output
    $html_header = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Server Drive Space</title>
    <style type="text/css">
    .serverName { text-align:center; font-family:"' + $server_name_font + '"; font-size:' + $server_name_font_size + `
    '; font-weight:bold; background-color: ' + $server_name_bg_color + '; border: 1px solid black; width: 150px; }
    .headings { text-align:center; font-family:"' + $heading_font + '"; font-size:' + $heading_font_size + `
    '; font-weight:bold; background-color: ' + $heading_name_bg_color + '; border: 1px solid black; width: 150px; }
    .data { font-family:"' + $data_font + '"; font-size:' + $data_font_size + '; border: 1px solid black; width: 150px; }
    #dataTable { border: 1px solid black; border-collapse:collapse; }
    body { background-color: ' + $background_color + '; }
    #legend { border: 1px solid black; ; right:500px; top:10px; }
    </style>
    <script language="JavaScript" type="text/javascript">
    <!--
    function zxcWWHS(){
    if (document.all){
    zxcCur=''hand'';
    zxcWH=document.documentElement.clientHeight;
    zxcWW=document.documentElement.clientWidth;
    zxcWS=document.documentElement.scrollTop;
    if (zxcWH==0){
    zxcWS=document.body.scrollTop;
    zxcWH=document.body.clientHeight;
    zxcWW=document.body.clientWidth;
    else if (document.getElementById){
    zxcCur=''pointer'';
    zxcWH=window.innerHeight-15;
    zxcWW=window.innerWidth-15;
    zxcWS=window.pageYOffset;
    zxcWC=Math.round(zxcWW/2);
    return [zxcWW,zxcWH,zxcWS];
    window.onscroll=function(){
    var img=document.getElementById(''legend'');
    if (!document.all){ img.style.position=''fixed''; window.onscroll=null; return; }
    if (!img.pos){ img.pos=img.offsetTop; }
    img.style.top=(zxcWWHS()[2]+img.pos)+''px'';
    //-->
    </script>
    </head>
    <body>'
    $html_footer = '</body>
    </html>'
    # Start to create the reports file
    Add-Content $html_file $html_header
    # Retrieve the contents of the server.txt file, this file should contain either the
    # ip address or the host name of the machine on a single line. Loop through the file
    # and get the drive information.
    Get-Content $server_file |`
    ForEach-Object {
    # Get the hostname of the machine
    $hostname = Get-WmiObject -Impersonation Impersonate -ComputerName $_ -Query "SELECT Name From Win32_ComputerSystem"
    $name = $hostname.Name.ToUpper()
    Add-Content $html_file ('<Table id="dataTable"><tr><td colspan="3" class="serverName">' + $name + '</td></tr>
    <tr><td class="headings">Drive Letter</td><td class="headings">Total Size</td><td class="headings">Free Space</td></tr>')
    # Get the drives of the server
    $drives = Get-WmiObject Win32_LogicalDisk -Filter "drivetype=3" -ComputerName $_ -Impersonation Impersonate
    # Now that I have all the drives, loop through and add to report
    ForEach ($drive in $drives) {
    $space_color = ""
    $free_space = $drive.FreeSpace
    $total_space = $drive.Size
    $percentage_free = $free_space / $total_space
    $percentage_free = $percentage_free * 100
    If ($percentage_free -le 5) {
    $space_color = $very_low_space
    }elseif ($percentage_free -le 10) {
    $space_color = $low_space
    }elseif ($percentage_free -le 15) {
    $space_color = $medium_space
    Add-Content $html_file ('<tr><td class="data">' + $drive.deviceid + '</td><td class="data">' + (ConvertBytes $drive.size) + `
    '</td><td class="data" bgcolor="' + $space_color + '">' + (ConvertBytes $drive.FreeSpace) + '</td></tr>')
    # Close the table
    Add-Content $html_file ('</table></br><div id="legend">
    <Table><tr><td style="font-size:12px">Less then or equal to 5 % free space</td><td bgcolor="' + $very_low_space + '" width="10px"></td></tr>
    <tr><td style="font-size:12px">Less then or equal to 10 % free space</td><td bgcolor="' + $low_space + '" width="10px"></td></tr>
    <tr><td style="font-size:12px">Less then or equal to 15 % free space</td><td bgcolor="' + $medium_space + '" width="10px"></td></tr>
    </table></div>')
    # End the reports file
    Add-Content $html_file $html_footer
    # Email the file
    $mail = New-Object System.Net.Mail.MailMessage
    $att = new-object Net.Mail.Attachment($html_file)
    $mail.From = $from_address
    $mail.To.Add($to_address)
    $mail.Subject = "Server Diskspace $date"
    $mail.Body = "The diskspace report file is attached."
    $mail.Attachments.Add($att)
    $smtp = New-Object System.Net.Mail.SmtpClient($email_gateway)
    #$smtp.Credentials = New-Object System.Net.NetworkCredential($smtp_user,$smtp_pass)
    $smtp.Send($mail)
    $att.Dispose()
    # Delete the file
    Remove-Item $html_file
    Regards,
    Denis Cooper
    MCITP EA - MCT
    Help keep the forums tidy, if this has helped please mark it as an answer
    My Blog
    LinkedIn:

  • How do I install the jdbc driver for sql server 2005, in sql developer 4.0 ?

    Hallo together
    I need access to tables in a MS SQL Server 2005 database.
    One possibility is the JDBC driver.
    How do i install this driver ?
    Thank you very much for your postings.

    Hi,
      This is from the documentation -
    Database: Third Party JDBC Drivers
    The Third Party JDBC Drivers pane specifies drivers to be used for connections to third-party (non-Oracle) databases, such as IBM DB2, MySQL, Microsoft SQL Server, or Sybase Adaptive Server. (You do not need to add a driver for connections to Microsoft Access databases.) To add a driver, click Add Entry and select the path for the driver:
    For Microsoft SQL Server or Sybase Adaptive Server: jtds-1.2.jar, which is included in the jtds-1.2-dist.zip download
    To find a specific third-party JDBC driver, see the appropriate website (for example, http://www.mysql.com for the MySQL Connector/J JDBC driver for MySQL, http://jtds.sourceforge.net/ for the jTDS driver for Microsoft SQL Server and Sybase Adaptive Server, or search at http://www.teradata.com/ for the JDBC driver for Teradata). For MySQL, use the MySQL 5.0 driver, not 5.1 or later, with SQL Developer release 1.5.
    You must specify a third-party JDBC driver or install a driver using the Check for Updates feature before you can create a database connection to a third-party database of that associated type. (See the tabs for creating connections to third-party databases in the Create/Edit/Select Database Connection dialog box.)
    Alternative:
    As an alternative to using this preference, you can click Help, then Check for Updates to install the JTDS JDBC Driver for Microsoft SQL Server and the MySQL JDBE Driver as extensions.
    Regards,
    Mike

  • [SOLVED] Use the nouveafb as framebuffer and the nv driver for Xorg

    Hi! I'm using Arch on a JAMMA Arcade cabinet (one of those old arcade cabinet) so i need some strange video resolution to suit my needs.
    The best option is a 640x240 @ 60Hz vertical and 15Khz horizontal. Arcade screens must have an horizontal frequency of 15Khz or I'll fry my screen! Luckily i use a card called J-PAC that cut off the video signal if is not 15Khz.
    With Xorg there's no problem if i use the nv driver, using this Modeline do the trick:
    # 640x240x60.00 @ 15.240kHz Perfect screen mode for Xorg
    Modeline "640x240x60.00"  12.192000  640 656 720 800  240 244 248 254  -HSync +VSync
    I've found this modeline using a little program called umc: http://aur.archlinux.org/packages.php?ID=27550
    Instead Xorg crash randomly if I use the same modeline with the nouveau driver, sometimes at startup, other times during the Xorg session. I use some "no edid" options that let me use strange video resolutions but i don't know if this is bothering the nouveau driver or not, surely it isn't bothering the old dear nv driver.
    BUT WAIT!!!!
    The nv driver can be loaded only if the nouveau driver is not loaded!
    So if I use the nv driver for Xorg i lose the nouveafb, and the nouveafb is the only one that works for me 'cause i can't force a non standard video resolution like 640x240@60hz on vesa and uvesafb! At least this is what i've learned from the docs, tell me if i'm wrong: http://git.kernel.org/?p=linux/kernel/g … vesafb.txt
    For now the only thing that make the framebuffer works at 640x240 is this: video=DVI-I-1:640x240@60eMm but this kernel command works only with KMS and the nouveafb.
    So my question is, can i use the nouveau driver for framebuffer only ? and the NV driver for Xorg ?
    Or there is another approach ?
    I remind you that i need a resolution of 640x240 both on the framebuffer and on Xorg, i'm using an old GeForce4 Ti4600 that is supported by nouveau (chip NV20).
    Thank for your patience and your time. 
    Bye for now.
    Last edited by marcs (2011-06-28 12:05:13)

    Hi
    It seems (well for now all is stable)... that now I got a more stable situation loading the nouveau module directly from initramfs.
    I'm guessing that now this is the solution, is the only thing i've changed, now fbsplash works also on start. (yay!)
    For solution documenting, you can do the same doing like this:
    1. edit the /etc/mkinitcpio.conf file with nano, vim or whatever.
    2. Add at the MODULES="" the nouveau module like this: MODULES="nouveau"
    3. Add the modprobe.conf file to the FILES="" line, like this: FILES="/etc/modprode.d/modprobe.conf"
    4. OPTIONAL: If you are using fbsplash like me you must add at the HOOKS also the fbsplash script like this: HOOKS="base udev fbsplash ..." : look here: https://wiki.archlinux.org/index.php/Fbsplash
    5. OPTIONAL: On an arcade cabinet the best text font must be tiniest possible like an 8x8. I'm using cp865-8x8 wich is much better than Agafari-16 that is good for high resolutions. To use this console font as soon as possible you can add also consolefont to the HOOKS like, like this: HOOKS="...[stuff before] consolefont"; look here: https://wiki.archlinux.org/index.php/Fo … fault_font.
    6. Then you must remake the initramfs images doing this: mkinitcpio -p kernel26 (or whatever kernel you wan't to use as a model, i'm using kernel26-fbcondecor).
    To use fbcondecor, you can find the kernel26-fbcondecor package from AUR: http://aur.archlinux.org/packages.php?ID=15603 (please support this package)
    Xorg seems very stable for now. I'm using the nouveafb framebuffer with fbsplash on an old arcade cabinet and that's some fine eye candy man!
    PROBLEM SOLVED!
    BUT WAIT!!!
    I have to know now what's the difference between loading nouveau from initramfs... I don't know if the problem is related to nouveau or KMS or fbcondecor, or fbsplash, or the kernel I'm not so good to know that.
    Now can any kernel guru tell me what is the basic difference by loading a module from initramfs instead making the kernel load it, a part the fact that is loaded a bit earlier from initramfs. There are also difference between memory areas ?
    I'll send a bug report and how to reproduce it, but i guess that my configuration is a bit out of the mainstream...
    Thank to anyone that have taken a look at this post.

  • Finding the ASIO driver for Sound Blaster ZS

    Finding the ASIO driver for Sound Blaster ZS
    And One More question
    Anybody are using the Guitar Rig (Guitar effect software)
    How to detect the Sound Blaster ZS sound card with WDM Driver

    shlomokg wrote:
    Hello,
    I am trying to use my Sound Blaster LX with the new Adobe Audition 2.0 with no luck.
    With the new version 2.0, Audition came with this ASIO solution that should make things easier.
    Somehow for me it does not work.
    Please advise, what should I do that Audition will work with my sound card?
    Thanks,
    Shlomo
    Perhaps Asio4All or USB-ASIO (LX not said to be supported) driver is needed to be installed to get a sort of ASIO support for that USB device.
    jutapaMessage Edited by jutapa on 07-2-2006 07: PM

  • Powershell script to change the a column value of all documents in a site.

    Hi,
    I need a powershell script to change the value of a column (a site column which has been added to all document libraries) in all documents in a site,
    For example: 
    -column 1 is a site column added to all libraries
    the value of column 1 of all documents under this site: http://intranet.doman/ex1 should be equal to V1
    the value of column 1 of all documents under this site: http://intranet.doman/ex2 should be equal to V2
    So, if I can write a powershell script to change the value of all documents in a site, I can modify it for different site that I have and run it for each of them individually,

    cls
    # Is dev version?
    $dev = $false
    # Configuration
    $termStore = "Managed Metadata Service"
    $group = "G1"
    $subjectMatterTermSetName = "Subject Matter"
    # Check if SharePoint Snapin is loaded
    if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) {
         Add-PSSnapin Microsoft.SharePoint.PowerShell
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Taxonomy") | Out-Null
    function GetTermStore($site, $termStore, $group, $termSet) {    
        $session = New-Object Microsoft.SharePoint.Taxonomy.TaxonomySession($site)
        $termStore = $session.TermStores[$termStore]
        $group = $termStore.Groups[$group]
        $termSet = $group.TermSets[$termSet]
        return $termSet
    if($dev) {
        Write-Host "Running DEV version..."
        $webUrl = "http://Site1"   
        $libraryName = "L1"
        $subjectMatter = "C1"
    } else {
        $webUrl = Read-Host "Enter Site URL" 
        $libraryName = Read-Host "Enter Document Library name"
    $subjectMatter = Read-Host "Enter Subject Matter"
    try {
        $web = Get-SPWeb $webUrl
        $site = $web.Site
        $library = $web.Lists[$libraryName]
        $items = $library.GetItems()
        $subjectMatterTermSet = GetTermStore $site $termStore $group $subjectMatterTermSetName
        $subjectMatterTerm = $subjectMatterTermSet.GetTerms($subjectMatter,$true) | select -First 1
        foreach($item in $items) {
            if([string]::IsNullOrEmpty($item["Subject Matter"])) {     
                #Write-Host "Filename: $filename / Keywords: $keywords / Subject Matter: $subjectMatter / Document Type: $documentType"        
                Write-Host "Updating $($item["ows_FileLeafRef"])..."           
                # Set Subject Matter column
                $subjectMatterField = [Microsoft.SharePoint.Taxonomy.TaxonomyField]$item.Fields["Subject Matter"]
                $subjectMatterField.SetFieldValue($item,$subjectMatterTerm)
                # Update Item
                $item.SystemUpdate()
    catch
        $ErrorMessage = $_.Exception.Message
        Write-Host "Something went wrong. Error: $ErrorMessage" -ForegroundColor Red

  • Script to cleanup the C drive

    Hi,
    I have SCOM 2007 R2 installed in our environment.  I need to cleanup the C drive space through powershell script. I have already prepared a powershell script. When we manually run the script through powershell, it clears the space from temp directory
    and other locations, which is futile. Now, my question is:
    Can I schedule the script through SCOM so that every time the alert for C drive appears, the script could run automatically and clear the space in C drive?
    Regards

    Hi Gautam,
    I am using PS1 file. I copied the PS1 file at the same location on couple of servers and executed the script through command line rule- scom 2007 r2.
    I have one query. I have developed a powershell script to check the high memory consumption processes and created a diagnostic task for the alert "Available Megabytes of Memory is too low". Therein, during the creation of a diagnostic
    task, the target was by default set to Windows Server 2008 R2 Operating System. I tried to create the task by providing the below details:
    Post providing the parameters, I tried to create it, but it was throwing some error about the target, so I changed the target to Windows 2008 r2 core operating system. After the creation, the script is not yielding any results. However, when I created the
    command line rule with some interval, it was running fine, but that will not suffice the requirement. 
    Any suggestions on that.
    Kind Regards.

  • I created boolean references in my main vi block diagram and copied them to my sub vi front panel. when wire my reference in my main vi to one the input node of the sub vi the wire is broken. the error says its a class conflict why?

    i created boolean references in my main vi block diagram and copied them to my sub vi front panel. when wire my reference in my main vi to one the input node of the sub vi the wire is broken. the error says its a class conflict why?

    Expanding and clarifying what BJD said;
    After you create the temporary sub-VI that BJD mentioned, open its front panel and copy the reference control that LV created when it created the sub-VI.
    This reference control will be correct class etc that you need. Use the control to replace the original control that you were attempting to wire up.
    The technique of "create sub-VI...copy" always works for me.
    There is one more thing that you should watch out for.
    The mechanical action of the boolean can not be set for latch action when attempting to read the value using a value property node.
    Trying to help,
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

Maybe you are looking for