Windows – Creating a USB System Repair Disc

October 27, 2014

More and more laptops are getting smaller and light weighted. Meaning they are running on SSD hard disks, but lacking a DVD drive in most cases.

So bottom line, even if you created a System Image (Win 7).

image

You will need a System Repair Disk to install the image again.

image

Unfortunately Win 7 only gives you the possibility to write to a DVD drive Sad smile

Solution Windows 7 :

Download TotalMounter from KernSafe (don’t use this on Windows 8 or later ! )

image

After installing the software, you can start it, and choose Mount.

image

Next select Virtual CD/DVD-RW

image

Create a new file of type CD, leave the Size default, and point to a folder where you want to create the the ISO file (give it a name like Repair in this case).

And finish

image

It will show up as a physical DVD Drive (F:)

image

Next start the create System Repair Disc.

image

It will recognize the DVD drive. Run it and check the result.

image

If all goes well you will see the ISO file that contains the Repair Disc files.

image

Open it using for example 7-Zip and extract the files.

image

Once extracted you can copy the files to a USB pen drive.

But make sure you have your USB drive properly prepared (be aware that it will erase all existing data on the USB drive) :

Open the command prompt: “Run” -> CMD
And then type the following commands:

  • DISKPART
    • (This command will open a new window called “diskpart”)
  • Type => list disk
    • (Look for the No. assigned to your USB key from the list that appears. Based on the size you are able the find it)
  • Type => select disk 1
    • (Where No. 1 correspond to your USB key. And No. 0 might be your hard drive)
  • Type => clean
    • (This will delete this partition)
  • Type => create partition primary
    • (Create a new partition)
  • Type => active
    • (This will make your partition active – bootable)
  • Type => format fs=fat32 quick
    • (Quick format in “fat32”)
  • Type => assign
    • (To assign a letter to your USB drive)
  • Type => exit
    • (To exit diskpart.exe)
  • Type => exit
    • (To close the initial command prompt)
  • Now your are ready to copy the files accross

image

That’s it, you just created a USB repair drive for Windows 7.

A Different method you can use is to run the create System Repair disc as is.

image

Since you don’t have a DVD drive it will fail. But if you go to the %Temp% folder you can see the file being created

image

You need use a File Unlocker to get hold of it.

Solution Windows 8 :

For it is a bit easier, because it can natively write to a DVD and a USB stick.

image

But you can use the old school method as well, using recdisc.

image

image

Some Tips :

Now that you have the repair tools, you are not out of the woods yet?

When booting you may have saved the Image to a network drive or NAS in your network.

Well don’t be surprised that you won’t get access to the drive, because the network driver you need is not loaded during booting.

So my tip is download the drivers and store them as well on the USB drive.

Or use the Double Driver Backup Tool. Which extracts all drivers and saves them in a ZIP or in Folders.

image

This tool is available as a stand alone tool no installation needed as well.

So now you are fully equipped.

Hopefully you will never need it, but you never know !

Saved me some headaches Smile

Advertisements

Windows – Installing FileZilla FTP Server

October 19, 2014

I could not make a connection to a FileZilla FTP server.

I installed the FTP Server and I could not connect from the internet facing side ?

I could connect on the server itself though, using the commandline FTP.exe

image

I checked to firewall where I had installed a NAT rule and all was fine Confused smile

So it must be something with the local Windows Firewall.

Some years back I created a Windows log File Analyzer application using AutoIT. It’s dating from the XP timeframe but still working on Windows 2008r2 Smile

image

image

You need to activate the Firewall Logging, and can find the log file here.

%systemroot%\system32\LogFiles\Firewall\pfirewall.log

So as you can see the packet was dropped by the local firewall.

Solution is to the create a custom Inbound Rule for the FileZilla program.

image

image

%ProgramFiles% (x86)\FileZilla Server\FileZilla Server.exe

image

Since we have a firewall in front of the server facing the public internet, we can define for Domain only.

image

image

Everthing is working fine now.

PS : see here how to transfer the FileZilla Server settings


SharePoint – How to Cancel a Workflow that has not completed Successfully

October 14, 2014

Continuing on this List WF that have not been completed Successfully

Well here is the script to Cancel Workflows that have not been completed.

CLS

$web = Get-SPWeb "http://www.YourSite.com/"
$web.AllowUnsafeUpdates = $true;    

#Your List Name
$list = $web.Lists["YourListName"]
$count = 0

#Loop through all Items in List then loop through all Workflows on each List Items.         
foreach ($listItem in $list.Items) 
{
    foreach ($workflow in $listItem.Workflows) 
    {
        #Disregard Completed Workflows 
        if($Workflow.InternalState -ne "Completed" -and  $Workflow.InternalState -notlike "Cancelled*")
        {
            # Cancel Workflows        
            [Microsoft.SharePoint.Workflow.SPWorkflowManager]::CancelWorkflow($workflow)   
            Write-Host "Workflow cancelled for : " $Workflow.AssociationId " - " $Workflow.InternalState  " - "  $listitem.ID $listitem.Title $listitem.Title  
        }
    }
}
$web.AllowUnsafeUpdates = $false
$web.Dispose()

Enjoy !


SharePoint – How to list all Workflow Items that have not completed Succussfully

October 14, 2014

If have tons of Workflows running. But form time to time I have a number of WorkFlows running that did not complete successfully.

In order to investigate the which items it concerns I have this little PowerShell Script.

Once you know the Item ID you can go there and cancel the workflow process.

CLS

$web=get-spweb "http://www.yoursite.com/"

$list = $web.Lists["YourListName"]

write-host "# Records : " $list.ItemCount

$i = 0

foreach($wf in $list.WorkflowAssociations)
{

   if($wf.Name -eq "YourListName")
   {
       write-host $wf.Name " - " $wf.Id
       write-host ""

       foreach($listitem in $list.Items)
       {

          foreach($Workflow in $listitem.Workflows)
          {
            if($Workflow.InternalState -ne "Completed")
            {
             # if($Workflow.AssociationId -eq $wf.ParentAssociationId) # change to if needed
             # {
                 write-host $i $Workflow.AssociationId " - " $Workflow.InternalState  " - "  $listitem.ID $listitem.Title $listitem.Title
                 $i++
             # }
            }

          }
       }
   }
}

Later on I hope to create a Cancel WF PowerShell script. Well here it is


SharePoint – Cleanup & Maintenance

October 11, 2014

SharePoint Cleanup

As administrator you need to do regular cleanups.

In order to keep everything running smooth and have your database not to be oversized with digital waste.

A few things to keep track of :

1. Delete List Items that reflect a logging of some kind, needs to be cleaned.

cls
if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) {
    Add-PSSnapin Microsoft.SharePoint.PowerShell;
}

$sourceWebURL = "http://www.YourSharePoint.com/"
$sourceListName = "LogList"

$spSourceWeb = Get-SPWeb $sourceWebURL
$spSourceList = $spSourceWeb.Lists[$sourceListName]

$spSourceItems = $spSourceList.Items #| where {$_['ID'] -eq 1}

write-host $spSourceList.Items.count

$i = 0

$spSourceItems | ForEach-Object {

    Write-Host $i $_['ID'] $_['Title'] $_['Date']

    $itemID = $spSourceList.GetItemById($_['ID'])
    $itemID.delete()

    # $itemID.Recycle() # Moves it to the recyclebin instead
    $i++
}

2. Delete List Item Versions ?

CLS
if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null)
{
    Add-PSSnapin Microsoft.SharePoint.PowerShell;
}
# get site
$site = new-object Microsoft.SharePoint.SPSite("http://www.YourSite.com/")

# loop through webs
foreach ($web in $site.AllWebs)
{
  # loop through all lists in web
  foreach ($list in $web.Lists)
  {
    # examine if BaseType of list is NOT a Document Library
    if ($list.BaseType -ne "DocumentLibrary")
    {
      # forget the rest and return to top
      continue
    }
    # loop through each item
    foreach ($item in $list.Items)
    {
      # work with the file object as we're in a document library
      $file = $item.File
      Write-host $file.name
      Write-host " "
      Write-host $file.Versions
      delete all versions
      #$file.Versions.DeleteAll()
    }
  }
}

$web.Dispose();
$site.Dispose();

3. Maybe remove large attachments that are found double in your library.

CLS

if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null)
{
    Add-PSSnapin Microsoft.SharePoint.PowerShell;
}

$web=Get-SPWeb -identity "http://wss.YourSite.com/"

$list=$web.lists["YourList"];

foreach($item in $List.Items)
  {
        for($i=$item.Attachments.count-1; $i -ge 0; $i--)
        {
             if($item.Attachments[$i].endswith(".docx"))
             {
            write-host "File Deleted:" $item.Attachments[$i]
               #$Item.Attachments.Delete($item.Attachments[$i])
              } 

        }
          # $item.update()
  }

3. Delete Workflow History needs to be removed over time. In this case older then 60 Days.

cls
if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) {
    Add-PSSnapin Microsoft.SharePoint.PowerShell;
}

$sourceWebURL = "http://www.YourSite.com/"
$sourceListName = "Workflow History"

$spSourceWeb = Get-SPWeb $sourceWebURL
$spSourceList = $spSourceWeb.Lists[$sourceListName]

$spSourceItems = $spSourceList.Items | where {$_['Created'] -gt (get-date).AddDays(-60)} 

write-host $spSourceList.Items.count "in the list"
write-host " "

$i = 0

$spSourceItems | ForEach-Object {
    Write-Host $_['ID'] $_['List'] $_['WorkflowAssociation'] $_['Created'] $_['Description']
    $itemID = $spSourceList.GetItemById($_['ID'])
    $itemID.delete()
    # $itemID.Recycle() # Moves it to the recyclebin instead
    $i++
}

write-host " "
write-host "$i Selected"

4. Cleanup the Recycle Bin

cls
if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) {
    Add-PSSnapin Microsoft.SharePoint.PowerShell;
}

(Get-SPSite "http://YourSite/").RecycleBin | ?{$_.Title -match "System.NullReferenceException"}

(Get-SPSite "http://YourSite/").RecycleBin.DeleteAll()

After cleaning up a bit your can shrink your Content DB’s a bit to save some space

image

 

Enjoy


PowerShell – How to start a SharePoint Workflow

October 11, 2014

Ever needed to start a workflow for multiple List Items, or a selection of items.

This Example runs a WF on Customer Items in a list.

Well here we go :

CLS

if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null)
{
    Add-PSSnapin Microsoft.SharePoint.PowerShell;
}

start-spassignment -global
#
#Open the web site, list and the workflow

$site=get-spsite "www.SharePoint.com"
$web=get-spweb "www.SharePoint.com/YourSide"

#
#Open the library or list and workflow association
#
$affected = $web.getlist("http://www.SharePoint.com/Lists/Yourlist")
# WF Name
$wfname="Your Workflow" 

$manager=$site.workflowmanager
$culture=[system.globalization.cultureinfo]::currentculture

$association=$affected.workflowassociations.getassociationbyname($wfname,$culture)
$data=$association.associationdata
$wfrunoption=[microsoft.sharepoint.workflow.spworkflowrunoptions]::synchronous

#
#Start workflow
#
#File with all ID's where the WF should be started for.
#

$Customers = Get-Content "D:\Temp\_Customers.txt" 

Foreach ($ID in $Customers){

    foreach ($item in $affected.items) {

     If ($item["ID"] -eq $ID){
      Write-Host $item["ID"] 
       $site.workflowmanager.startworkflow($item,$association,$data,$wfrunoption)
    }
  }
}

stop-spassignment -global 

I hope it worked as well for you.


Oracle – ASP.Net Error [im003] Error

October 8, 2014

Error [im003] specified driver could not be loaded due to system error  5 (oracle in oracle9i)

I had a strange error when accessing an Oracle database over ODBC using an ASP.NET (4.0 framework) Application running on IIS 6.0.

The ASP.net page could not load the database tables while the ODBC manager gave no errors ?

image

In the eventviewer I saw a lot of ASP.NET 4.0.30319.0 – Event ID 1309

image

This showed definitely a security issue on the Oracle home directory.

image

Solution :

Oracle 9.2 Client software requires that you give the Authenticated User privilege to the Oracle Home by following these steps:

1. Log on to Windows as a user with Administrator privileges.

2. Launch Windows Explorer from the Start Menu and and navigate to the ORACLE_HOME folder. This is typically the “Ora92” folder under the “Oracle” folder (i.e. C:\Oracle\Ora92).

3. Right-click on the ORACLE_HOME folder and choose the “Properties” option from the drop down list. A “Properties” window should appear.

4. Click on the “Security” tab of the “Properties” window.

5. Click on “Authenticated Users” item in the “Name” list (on Windows XP the “Name” list is called “Group or user names”).

6. Clear the “Read and Execute” box in the “Permissions” list under the “Allow” column (on Windows XP the “Permissions” list is called “Permissions for Authenticated Users”).

7. Re-check the “Read and Execute” box under the “Allow” column (this is the box you just unchecked).

8. Click the “Advanced” button and in the “Permission Entries” list make sure you see the “Authenticated Users” listed there with:

· Permission = Read & Execute
· Apply To = This folder, subfolders and files

If this is NOT the case, edit that line and make sure the “Apply onto” drop-down box is set to “This folder, subfolders and files”. This should already be set properly but it is important that you verify this.

9. Click the “OK” button until you close out all of the security properties windows. The cursor may present the hour glass for a few seconds as it applies the permissions you just changed to all subfolders and files.

10. Reboot your computer to assure that these changes have taken effect. (no need for this in my case).

11. Re-execute the application and it should now work.

This made it works like a charm !

Reason was that IIS user did not have enough permission on the folders and subfolders ?