Windows PowerShell is a fantastic tool; SharePoint 2010 has literally hundreds of different PowerShell Cmdlets that are available out of the box,
if you don’t believe me check this out - http://technet.microsoft.com/en-us/library/ff678226.aspx. What about MOSS 2007? Whilst there aren’t any native Cmdlets for MOSS 2007, PowerShell can be used to access the SharePoint object model directly instead and in most cases achieve the same objectives, this isn’t as daunting as it sounds.
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
#Configure the location for the output file
$Output="C:\amar\Output.csv";
"Site URL"+","+"Owner Login"+","+"Owner Email"+","+"Root Site Last Modified"+","+"Quota Limit (MB)"+","+"Total Storage Used (MB)"+","+"Site Quota Percentage Used" | Out-File -Encoding Default -FilePath $Output;
#Specify the root site collection within the Web app
$Siteurl="http://370dw7e07621";
$Rootweb=New-Object Microsoft.Sharepoint.Spsite($Siteurl);
$Webapp=$Rootweb.Webapplication;
#Loops through each site collection within the Web app, if the owner has an e-mail address this is written to the output file
Foreach ($Site in $Webapp.Sites)
{
if ($Site.Quota.Storagemaximumlevel -gt 0)
{
[int]$MaxStorage=$Site.Quota.StorageMaximumLevel /1MB
}
else {$MaxStorage="0"};
if ($Site.Usage.Storage -gt 0)
{
[int]$StorageUsed=$Site.Usage.Storage /1MB
};
if ($Storageused-gt 0 -and $Maxstorage-gt 0)
{
[int]$SiteQuotaUsed=$Storageused/$Maxstorage* 100}
else
{ $SiteQuotaUsed="0" };
$Web=$Site.Rootweb; $Site.Url + "," + $Site.Owner.Name + "," + $Site.Owner.Email + "," +$Web.LastItemModifiedDate.ToShortDateString() + "," +$MaxStorage+","+$StorageUsed + "," + $SiteQuotaUsed | Out-File -Encoding Default -Append -FilePath $Output;$Site.Dispose()};
Wednesday, April 23, 2014
Interating with DOM (Jquery)
Interacting with DOM :
Iterating through Nodes,
Modifying Dom Object
Modifying Attributes
Adding and removing Nodes
Modifying Styles
Modifying Classes
Iterating Through Nodes :
.each(function(index,Element)) is used to iterate through
Jquery Object.
$(‘div’).each(function(index)
{Alert(index+ ’=’ +$(this).text());
});
Iterates through each div element and returns its index
number and text.
$(‘div’).each(function(index,elem)
{Alert(index+ ’=’ +$(elem).text());
});
Elem = this
Example :
Div id are blueDIv
and RedDiv
$(documents).ready(function(){
Var output= $(‘#outputDIv);
$(‘div.bluediv,div.reddiv’).each(function
(index)
{
Output.html(output.html()+”</br>”
+ index+ “ ” + $(this).text())}
});
This means raw DOM object
Modifying DOM Objects Properties :
The This.PropertyName statement can be used to modify
an object’s Properties directly:
$(‘div).each(function(i)
{ This.title=”my Index=” +i;
});
Iterates through each div and
modifies the title. If the property does not exist ,it will be added.
Modifying Multiple
Attributes :
TO modify multiple
attributes, Pass a JSON Object
containing Name/Value Pairs : All the image |
$(‘img’).attr ({
Title: ‘My Image
Title;,
Style:’border:2px
solid back;’
});
Json Object passed and used
to change title and border
Modifying Attributes :
Objecct attribures can be
accessed using attr();
Var
val=$(‘#CustomerDiv’).attr(‘title’);
Retrieves the values of the
Title attribute :
.attr(attributeName,Value) is the
method used to access an object attributes modify the value:
$(‘img’).attr(‘title’,’My
Image Title’);
Change the title attribute to
a value of my image Title.
Whats, Json :
JSON Delimits object
using {
and }
The :
character separates properties and values {
FirstName :
‘jhon’,
LastName : ‘Doe’,Address : // THis is nested Json object
{
Street : ‘1234 anywhere st ,’,
City : ‘GA’,State : ‘AX’
Zipcode : 85675
}
}
Four key methods handle
inserting nodes into elements:
.append()
.appenTo().prepend()
.prependTo()
To remove node from an
element use . Remove()
$(‘<Span>
(office) </span>’).appendTo(‘.officePhone’);
Or
$(‘.officePhone’).append(‘<span>(office)</span>’);
Would result in (office)
being added into each .officephone class element
Wrapping Elements :
<div class=”State”>
Arizona<div>
$(‘.state’).wrap(‘<div
class=”US_State” />’);
Result:
<div class=”US_State”>
<div class=”State”>Arizona </div>
</div>
.remove :
$(‘.phone,.location’).remove();
Modifying Styles :
The .css() function can be used to modify an object’s
style :
$(“div”).css(“color”,”red”);
All the DIVs
Multiple styles can be
modified by passing a JSON object :
$(‘div’).css(
{
‘color’:’#ccff’,
‘font-weight’:bold’
});
Modifying Classes :
The four methods for working
with CSS class attributes are :
.addClass()
.hasClass()
.removeClass()
.toggleClass()
Example :
$(‘p’).addClass(‘ClassOne’);
More than once
class :
$(‘p’).addclass(‘classOne ClassTwo’);
.hasClass() return true if the selected element has a matching
class that is specified :
If($(‘p’).hasClass(‘styleSpecifi’))
{
// perform work
}
.removeCLass() can remove one
or more classes :
Remove all class attribures
for the matching selector
$(‘p’).removeclass();
Toggling CSS Classes
:
.toggleClass() alternates adding or removing a class based on the
current presence or absence of the class
$(‘#phoneDetails’).toggleClass(‘highlight’);
<style type=”text\css”>
.highlight { background:yellow; }
</style>
Example :
$(‘input[type=’text’]’).addclass(Highlight);
Example ( Text allows only charters)
HTML :
Number : <input type="text" name="quantity" id="quantity" />
phone : <input type="text" name="namePhone" id="idphone"/>
<span id="errmsg">
</span>
Jquery
$(document).ready(function () {
//called when key is pressed in textbox
$("#quantity ,#idphone").keypress(function (e) {
//if the letter is not digit then display error and don't type anything
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
//display error message
$("#errmsg").html("Digits Only").show().fadeOut("slow");
return false;
}
});
});
CSS :
#errmsg
{
color: red;
}
Example ( Text allows only charters)
HTML :
Number : <input type="text" name="quantity" id="quantity" />
phone : <input type="text" name="namePhone" id="idphone"/>
<span id="errmsg">
</span>
Jquery
$(document).ready(function () {
//called when key is pressed in textbox
$("#quantity ,#idphone").keypress(function (e) {
//if the letter is not digit then display error and don't type anything
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
//display error message
$("#errmsg").html("Digits Only").show().fadeOut("slow");
return false;
}
});
});
CSS :
#errmsg
{
color: red;
}
Tuesday, April 15, 2014
Finding and Installing a NuGet Package Using the Package Manager Console
This topic describes how to find, install, remove, and update NuGet packages using PowerShell commands. You can also work with packages using the Manage NuGet Packages dialog box. For more information, see [Using the Manage NuGet Packages dialog](Using-the Add-Library-Package-Reference-Dialog-Box).
Using PowerShell commands is required if you want to install a package without having a solution open. It's also required in some cases for packages that create commands that you can access only by using PowerShell.
, select
The two drop-down lists set default values that let you omit parameters from the commands you enter in the window:
Example :
Get-Package -ListAvailable ( This will return all the packages)
Get-Package -Filter Jquery -ListAvailable (This will return jquery available packages)
Install-Package Jquery << ProjectName>>
Refer the below screen for more information:
Using PowerShell commands is required if you want to install a package without having a solution open. It's also required in some cases for packages that create commands that you can access only by using PowerShell.
Finding a Package
From the Tools menuLibrary Package Manager and then click Package Manager Console., select
The two drop-down lists set default values that let you omit parameters from the commands you enter in the window:
- In the Package source list, select the default source (NuGet package feed) that you want your commands to use. Typically you will leave this as its default value of NuGet official package source. For more information about alternative feeds, see Hosting Your Own NuGet Feeds.
- In the Default project list, select the default project that you want your commands to work with. (The default value will be the first project in the solution, not necessarily the one you have selected in Solution Explorer when you open the window.)
Get-Package -ListAvailable
at the prompt to see a list of all packages that are available in the selected package source.Example :
Get-Package -ListAvailable ( This will return all the packages)
Get-Package -Filter Jquery -ListAvailable (This will return jquery available packages)
Install-Package Jquery << ProjectName>>
Refer the below screen for more information:
Subscribe to:
Posts (Atom)