w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Powershell 2.0 - Remove Group Membership for List of Disabled Accounts
It's generally a good idea to also provide a sample of the data you're operating on (in this case, what the contents of users.csv looks like), since the key to resolving the problem could lie in the data you're reading in. However, in this case I believe I can see what's tripping you up without seeing the data. Keep in mind that in each stage of the pipeline, $_ is set the the values of each of the objects from the previous stage of the pipeline. $_.member doesn't have a consistent value throughout the pipeline. In the second stage, ForEach-Object {Get-ADPrincipalGroupMembership -Identity $_.member, $_.member evaluates to the values of the "member" column of the CSV file. In the third stage, ForEach-Object {Remove-ADPrincipalGroupMembership -Identity $_.member -MemberOf SamAccountName},

Categories : Powershell

Getting client ip address in Global.asax.cs - is it possible?
Application_Start() is not right event, in which you can do this. It will not run for every request from your user, it does some basic initialization of asp.net application. Better solution is to user, for example protected void Application_BeginRequest(){} which runs on beginning of request from client. About earliest event, in which both request and session will be available... Seems like it is void Application_AcquireRequestState(object sender, EventArgs e) { if (System.Web.HttpContext.Current.Session != null) { if (Session["locale"] != null) { //already set variable. } else { //set some variable Session["locale"] = "code"; } } } But what exactly do you want to yo

Categories : C#

How to catch an error from removing a webpart with powershell?
I tried to duplicate your issue and gave it a try. This time I removed -ErrorAction Stop and it still went into the Catch Block. The trick may be I think is to have Catch [System.Exception] block in place (not sure because in attempt 3 I removed -ErrorAction and [System.Exception] and it still went into Catch block. And just as Hyper Anthony suggested in the comment -ErrorAction Stop is supported in all commands so it should work. The script in the following function throws error on purpose to test the logic. I think your RETRACT function is throwing error. Attempt1 -Without -ErrorAction Function Remove { C:scriptssoDeletedFiles.ps1 } try { Remove } Catch [System.Exception]{ Write-Host "Unhandled Exception occurred" } It works fine - Lands into Catch Block. Attempt2 With -Error

Categories : Powershell

Passing pointer address to global variable
Your question isn't entirely clear. My first interpretation of what I thought you're trying to do, it would be something like this: unsigned char **buffptr; int functionexp(unsigned char *buff){ buffptr = &buff; //start interrupt //wait for end of interrupt //pass original pointer back with updated results // after this point, the value of buffptr is completely useless, // since buff doesn't exist any more! } void __attribute__((interrupt, no_auto_psv)) _DMA2Interrupt(void) { *buffptr = somedata; // this changes the 'buff' variable in functionexp } On the other hand you could simply mean this: unsigned char *globalbuff; int functionexp(unsigned char *buff){ globalbuff = buff; //start interrupt //wait for end of interrupt //pass o

Categories : C

How do I get address lists (NOT global) using Exchange WebServices in C#
I don't have exchange setup to test this code, so it will need modifications but it should give you a starting point to explore. The idea is that you set the ItemView to the ContactSchema to retrieve results by company. // Get the number of items in the Contacts folder. To keep the response smaller, request only the TotalCount property. ContactsFolder contactsfolder = ContactsFolder.Bind(service, WellKnownFolderName.Contacts, new PropertySet(BasePropertySet.IdOnly, FolderSchema.TotalCount)); // Set the number of items to the smaller of the number of items in the Contacts folder or 1000. int numItems = contactsfolder.TotalCount < 1000 ? contactsfolder.TotalCount : 1000; // Instanti

Categories : C#

Removing part of a link address with .htaccess
Assuming this is the entire file, your url category/show/music is rewritten to index.php?url=category/show/music. The following rewrite would 'insert' show for the index page. It would however be more sensible to edit index.php. RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d Options -Indexes RewriteRule ^(.*)/(.*)$ index.php?url=$1/show/$2 [L,QSA]

Categories : PHP

Using PowerShell in nuget package to edit Global.asax
from what I can see, there is some problem with this line since it will return nothing: $customGlobalAsax = $project.ProjectItems | ForEach-Object { $_.ProjectItems } | where { $_.Name -eq "Global.asax.cs" } The following is my test: $directory = dir * $directory | foreach {$_.name} The above run successfully. But the following returns nothing: $directory = dir * $directory.name | foreach {$_.name} I believe in the latter case $_.name represents $directory.name.name which doesn't exist. So it seems like this line in your script $customGlobalAsax = $project.ProjectItems | ForEach-Object { $_.ProjectItems } | where { $_.Name -eq "Global.asax.cs" } should be changed to: $customGlobalAsax = $project | ForEach-Object { $_.ProjectItems } | where { $_.Name -eq "Global.asax.cs

Categories : C#

ForEach-Object removing lines from a file using Powershell
This is your culprit: if ($_.indexof("$KEYWORD") -ge 0) { if ($KEYWORD -eq "SEQUENCE" -and $_.indexof("MINVALUE") -ge 0) { ... $_ -replace "CREATE $KEYWORD", $SQL } else { $_ -replace "CREATE $KEYWORD", "CREATE OR REPLACE $KEYWORD" } } Only the 2 $_ -replace ... produce output that the pipe redirects into Set-Content. You seem to assume that the -replace operator modifies the content in $_ and that Write-Host $_ echoes the line into the pipe. Both is not the case. $_ -replace ... takes the value from $_, replaces matches it finds, and writes the modified string to STDOUT. Write-Host writes messages to the console, not to STDOUT. Add an else branch to echo the lines that don't contain any keywords and you should be fine: if ($_.indexof("$KEYWORD") -ge 0) { if ($KEYW

Categories : Powershell

Removing and then adding back a device in Devices and Printers using PowerShell
You could probably automate this using MS UI Automation from a Powershell script. Here's a hello world UIA Powershell script to get an idea of how to get started: [Reflection.Assembly]::LoadFile('C:Program FilesReference AssembliesMicrosoftFrameworkv3.0UIAutomationClient.dll') [Reflection.Assembly]::LoadFile('C:Program FilesReference AssembliesMicrosoftFrameworkv3.0UIAutomationTypes.dll') # Get the root/desktop element $rootElement = [Windows.Automation.AutomationElement]::RootElement # Print its Name and ClassName Write-Host "Note: In the managed UIA API, the desktop name is empty:" "'" + $rootElement.Current.Name + "'" Write-Host "Instead, you can identify the desktop by its ClassName, #32769:" "'" + $rootElement.Current.ClassName + "'" To go beyond that, you might benefit from the

Categories : Python

How to get and assign the address of exit library function to a global variable?
You should declare fp with the correct type (ie pointer to a function taking an int and returning nothing): void (*fp)(int) = &exit; Not sure what you are trying to do with the printf then. If you want to print the address use %p instead of %d.

Categories : C

Getting Email address of a Sharepoint 2010 PeoplePicker Column Value in PowerShell
$input = "70;#Anand, Amit 25;#Kumar, Prabhakar 982;#Owen, Martin D." $regex = "(?<id>d+);#(?<name>[.D]*)" $input | Select-String $regex -AllMatches | % { ForEach($match in $_.Matches) { New-Object PSObject -Property @{ Id = $match.groups["id"].value Name = $match.groups["name"].value } } } Should give you: Id Name -- ---- 70 Anand, Amit 25 Kumar, Prabhakar 982 Owen, Martin D. I've only tested this in PowerShell 3.0, but I think it should work in 2.0.

Categories : Powershell

Find the address that a global defined pointer is pointing to which used heap allocation
There is no definitive way to find a pointer in a target application. It take some practise and experience. A good start for your case would be to break at the start of the original CallMe function with a debugger and read ECX to get the original class pointer. Now you could set a memory breakpoint on it (or use cheat engine's "find out what accesses this address") and work from there to eventually end up in a static address from which you can always get the dynamic address of the class instance. If the class uses a virtual table because of polymorphism, you can locate the function pointer (ZInput::CallMe) in there. This is an example of a virtual function call you could find in your target application: CPU Disasm Address Hex dump Command 006A4F94 8B4E 38

Categories : C++

Comparing AD Group and a CSV in Powershell
My way of solving such a problem is to concatenate the two arrays of objects and then use Group-Object CmdLet. Just be carefull to have a column header in your CVS with the same name of the propery in the Get-ADGroupMember CmdLet. Import-Module ActiveDirectory $a = Import-csv .Data.csv $b = Get-ADGroupMember Test_Users $c = $a + $b | group-object -property XXXX Then you can loop through $c array to build a new object.

Categories : Powershell

Determining if a given user is in a given global group
You can do it like this: [reflection.assembly]::LoadWithPartialName("System.DirectoryServices.AccountManagement") $username = "samaccountname" $ct = [System.DirectoryServices.AccountManagement.ContextType]::Domain $user = [System.DirectoryServices.AccountManagement.UserPrincipal]::FindByIdentity($ct, $username) $g = $user.GetGroups() ( $g | select -expa name ) -contains 'groupname'

Categories : Powershell

Remove / hide the Bing map offline message when offline
You can either handle the LoadingError event per instance or extend the Map control yourself as described in this post. You can then remove the layer than contains the error message so that it's not shown to the user. public partial class CachedMap : Map { public CachedMap() : base() { base.LoadingError += (s, e) => { base.RootLayer.Children.RemoveAt(5); }; } }

Categories : C#

Security script based on Global Group?
Your Global Groups are probably just Active Directory Security groups. You can do this with not too much difficulty by using the builtin ASP.NET Role Provider, web.config entries to control which groups/roles can see which menu items, and binding your menu control to use a web.sitemap file. All of this combined with securityTrimmingEnabled. will ensure your menu options are shown to to users in the groups you have defined. If these are not AD groups, you can still do this but would have to create a Custom Role Provider which could check against your SQL Server groups or simply use the table you have already created. Your web.config location entries will end up looking something like this based on the example you provided, with entries for each of the pages you want to allow the user to s

Categories : C#

Powershell - Append Group Name and Members
#Create Custom Data Container $header = @("Group,Member") #Columns $temp = @() $data = @() $data += $header $SearchBase = "OU=Groups,DC=domain,DC=local" Get-ADGroup -filter * -SearchBase $SearchBase | % { #For Each Group $Groups = $_.name get-ADGroupMember -Identity $groups | % { #For Each Member $Members = $_.Name #Add Row $temp = "$Groups,$Members" $data += $temp } } #output data to csv $data | ConvertFrom-Csv | Export-Csv -Path c:inmembersof.csv -NoTypeInformation

Categories : Powershell

How do I return the index of a group of values from a list for a specific value in the group?
You can use next and enumerate: >>> list1 = [(12, "AB", "CD"), (13, "EF", "GH"), (14, "IJ", "KL")] >>> next(i for i,x in enumerate(list1) if 13 in x) 1 With a simple for-loop: for i, item in enumerate(list1): if 13 in item: print i break ... 1 Update: If the first item in each tuple is unique and you're doing this multiple times then create a dict first. Dicts provide O(1) lookup while lists O(N) >>> list1 = [(12, "AB", "CD"), (13, "EF", "GH"), (14, "IJ", "KL")] >>> dic = {x[0]:x[1:] for x in list1} Accessing items: >>> dic[12] ('AB', 'CD') >>> dic[14] ('IJ', 'KL') #checking key existence >>> if 17 in dic: #if a key exists in dic then do something #then do something

Categories : Python

Cannot use an aggregate or a subquery in an expression used for the group by list of a GROUP BY clause
You are using the HAVING clause like a WHERE clause. That is, you are trying to enforce data constraints that are NOT on aggregate or GROUP BY expressions. Move them to your WHERE clause instead. SELECT ( SUM(DWXP050.Premp) ) FROM DWXP050 LEFT JOIN [DWXP050 GL Class] ON [DWXP050 GL Class].Policy = DWXP050.Policy AND [DWXP050 GL Class].CDDESC = DWXP050.CDDESC AND [DWXP050 GL Class].TRDATE = DWXP050.TRDATE AND [DWXP050 GL Class].[Effective Date] = DWXP050.EFFDTE AND [DWXP050 GL Class].ASLOB = DWXP050.ASLOB AND [DWXP050 GL Class].AGENT = DWXP050.AGENT WHERE (( ( DWXP050.TRANS ) = '10' OR ( DWXP050.TRANS ) = '20' )) AND ( ( ( [DWXP050 GL Class].AGENT ) = '00000BP001' ) AND ( ( [DWXP050 GL Clas

Categories : SQL

How do I block an ip address from seeing a group of webpages?
You only want to block the directory /foo/, so create an .htaccess file in /foo/ (which, intuitively, will only apply to /foo/). Then, use the same syntax to block IP addresses as usual: order allow, deny deny from 127.0.0.1 allow from all I believe this returns a 403 - Forbidden. Not sure how you'd go about returning a 404. (You could just use the same page for 403 errors as you do for 404 errors, and it's unlikely the user will check the response status code) Edit: does user4035's answer work if you begin with RewriteEngine On?

Categories : Htaccess

powershell create apps group in metroUI
I think you need to use Export-StartLayout, modify the XML and then use Import-StartLayout http://technet.microsoft.com/en-us/library/dn283401(v=wps.630).aspx

Categories : Powershell

Removing singleton dimension of scan capture group
Array#flatten may help foo = "bar = everybody bar = say bar = hey bar = ho" foo.scan(/^bar = (.*)$/).flatten #=> ["everybody", "say", "hey", "ho"]

Categories : Ruby

Using Groupby to group a list and then group them again then based on a quantity
Basic idea: Sort groups by quantity. Iterate through from both sides, combining groups that add up to no more than max quantity. Pseudo-code: sort groups by quantity (biggest group first) i = 0 j = groups.size-1 while i <= j // if the indices met, pick either // if the two groups are larger than max quantity, simply pick the larger one if i == j || union(groups[i], groups[j]).size > maxQuantity output groups[i] i++ else output union(groups[i], groups[j]) i++ j-- If the elements are unique: union(groups[i], groups[j]).size = groups[i].size + groups[j].size LINQ? This is most likely beyond the capabilities of LINQ. As for the C# code, it should be simple enough to derive from the pseudo-code.

Categories : C#

Adding TFS Group, AD groups and setting permissions in powershell
ok I got it working now, just needed to add some escape charaters here and there

Categories : Tfs

PowerShell Send Popup Message to users in group
As far as I understand. You can execute the script on a remote computer, but the user will not see the popup. This is because the remote process is not allowed to interact with the user Desktop. PS : have a look to this answer I think that on XP you can use NET SEND in upper versions you have MSG.EXE or third party WinSent.

Categories : Powershell

How to split a list into a list of lists by removing a specific separation(Haskell)
I will try to help you develop the understanding of how to develop functions that work on lists via recursion. It is helpful to learn how to do it first in a 'low-level' way so you can understand better what's happening in the 'high-level' ways that are more common in real code. First, you must think about the nature of the type of data that you want to work with. The list is in some sense the canonical example of a recursively-defined type in Haskell: a list is either the empty list [] or it is some list element a combined with a list via a : list. Those are the only two possibilities. We call the empty list the base case because it is the one that does not refer to itself in its definition. If there were no base case, recursion would never "bottom out" and would continue indefinitely!

Categories : List

How to create a new list out of an existing list by removing duplicates and shifting values?
the simplest way i can see is the following: >>> from collections import OrderedDict >>> d = OrderedDict() >>> for (k, v) in [(12, "AB"), (12, "AB"), (12, "CD"), (13, None), (13, "DE"), (13, "DE")]: ... if k not in d: d[k] = set() ... d[k].add(v) >>> d OrderedDict([(12, {'AB', 'CD'}), (13, {'DE', None})]) or, if you want lists (which will also keep the value order) and don't mind being a little less efficient (because the v not in ... test has to scan the list): >>> d = OrderedDict() >>> for (k, v) in [(12, "AB"), (12, "AB"), (12, "CD"), (13, None), (13, "DE"), (13, "DE")]: ... if k not in d: d[k] = [] ... if v not in d[k]: d[k].append(v) >>> d OrderedDict([(12, ['AB', 'CD']), (13, [None, 'DE'])]) and f

Categories : Python

Removing class of nested list elements based off click on outer list element?
You need this on click of A- $(this).closest('ul').find('li.active').removeClass('active'); $(this).closest('li').addClass('active') Demo -------> http://jsfiddle.net/NrGGz/

Categories : Javascript

When I select contact name and address from contact list address data not retrieved
public ArrayList<String> getName(){ ArrayList<String> mdetail=new ArrayList<String>(); SQLiteDatabase db = this.getWritableDatabase(); String selectQuery = "SELECT "+COLUMN_PERSON_NAME+" from "+TABLE_DETAIL; Cursor mCursor = db.rawQuery(selectQuery, null); if(mCursor.moveToFirst()){ do { mdetail.add(mCursor.getString(mCursor.getColumnIndex(COLUMN_PERSON_NAME))); } while (mCursor.moveToNext()); } mCursor.close(); db.close(); return mdetail; } if Your data is Sucessfully added in your database just use this code to retreive from database and show in list view like this.... if (!db.exists()) { } else { mListName=baseMan

Categories : Android

Using a list as "list of indexes" to address elements of another list
You could use reduce(operator.getitem, index, mylist) Here is a complete example: import operator mylist = [[1,2,3],[4,5,6],[7,8,9]] index = [1,2] val = reduce(operator.getitem, index, mylist) print(val) For NumPy arrays, there is a simpler method: import numpy as np ... myarr = np.array(mylist) val = myarr[tuple(index)] print(val)

Categories : Python

Logging output of user disable and group removal - Powershell no Quest
A simple on-screen answer using Write-Host $userGroups | %{Write-Host "Removing user from group $_"; get-adgroup $_ | Remove-ADGroupMember -confirm:$false -member $SAMAccountName}

Categories : Powershell

Delete a list of files from a list of servers in powershell
$REMOVE is an array whose elements are each line of remove-list.txt. In \$computer$DESTINATION$REMOVE, $REMOVE expands to a list of the array's elements. There's nothing in your code that tells PowerShell to iterate through the elements of $REMOVE. You need an inner loop: foreach ($computer in $computerlist) { foreach ($file in $REMOVE) { Remove-Item "\$computer$DESTINATION$file" -Recurse } } BTW, what exactly is -Recurse intended to accomplish? Were you thinking that this would make Remove-Item iterate through an array of filenames at the end of the path? That's not what it does. The -Recurse switch tells Remove-Item to remove not only the item specified by the path, but all its children as well. If you're invoking Remove-Item on a filesystem, you'd use -Recurse with directorie

Categories : List

How to set Group Policy "Turn Off Automatic Root Certificates Update" vie Registry/Powershell?
Domain policies override local settings. That's how they're supposed to work (they'd be rather useless otherwise). If you want the policy disabled, disable or remove the policy in Group Policy Management or remove the computer from the domain.

Categories : Powershell

MPI and global object: All ranks have the object at same memory address?
MPI starts multiple processes using the same executable file. Usually this results in those processes having the same initial memory layout, with only the location of the stack and the location where different shared libraries are mapped possibly being different. In your case obj is an uninitialised static object and as such is placed in the BSS section, which is usually located right after the initialised data section. The amount of data is known in advance and the placement of the BSS section too - these are fixed by the linker. Therefore obj has the same location in each process created from that executable. This is not a problem for MPI since every process has its own virtual memory space and the addresses that you see are virtual addresses, valid only in the virtual memory space of t

Categories : C++

How to convert list of group-by objects into html unordered list in Java?
public String convertToHTML(ArrayList<CountData> stuffs){ StringBuilder sb = new StringBuilder() sb.append(“<ul> ”); for(CountData cd : stuffs){ sb.append(“<li>”+cd.getCountry()+” (“+cd.getCount()+”) ”); sb.append(“ <ul>); sb.append(“ <li>”+cd.getState()+” (“+cd.getCount()+”) ”); sb.append(“ <ul>); sb.append(“ <li>”+cd.getCity()+” (“+cd.getCount()+”) ”); sb.append(“ <ul>); sb.append(“ <li>”+cd.getMfc()+” (“+cd.getCount()+”)</li> ”); sb.append(“ </ul>); sb.append(“ </li>); sb.append(“ </ul>); sb.append(“ </li>); sb.app

Categories : Java

Using linq group by to get from a list of objects with a DateTime property to a list with an interval StartDate, EndDate
You can use GroupBy in combination with SelectMany and Aggregate for this: var setups = bookedRooms.GroupBy(x => Tuple.Create(x.TimePeriodId, x.VenueId)) .SelectMany(x => x.Aggregate( new List<EventSetup>(), AccumulateRooms)) .OrderBy(x => x.StartDate) .ToList(); List<EventSetup> AccumulateRooms(List<EventSetup> existingSetups, BookedRoom currentRoom) { var setup = existingSetups.LastOrDefault(); if(setup == null || setup.EndDate.AddDays(1) != currentRoom.Day.Date) { setup = new EventSetup { VenueId = currentRoom.VenueId, TimePeriodId = currentRoom.TimePeriodId, StartDate = currentR

Categories : C#

SignalR Adding/Removing Connections from a dictionary and finding Group values from dictionary
First of all, SignalR is pretty smart about not wasting resources when sending to groups without any subscriptions, so you should be fine sending to groups without any members as long as it's OK to waste a few cycles doing that. If you don't have too many organizations you can have a ConcurrentDictionary<int,int> with all your organization ids as your keys and the number of connected members as your value. In OnConnected and OnDisconnected in could use Interlocked.Increment and Interlocked.Decrement respectively to keep track of the currently connected members. Then in your task could loop over the keys and skip any organization with zero connected members. This new ConcurrentDictionary could replace _uniqueOrganizations if you don't mind calling key.ToString(CultureInfo.InvariantC

Categories : Asp Net

Group a list of list by nested size in R
To get all nested list of length equal to 1 you can do the following: P3[lapply(P3,length) ==1] ## get all elements with size equal to 1 $`2` [1] "a" $`3` [1] "b" $`5` [1] "c" Now, We can use this to group the nested lists by their lengths. We loop(lapply) over all unique lengths, and we perform the above statement for each length : lapply(unique(unlist(lapply(P3,length))), function(x) P3[lapply(P3,length) ==x] )

Categories : R

Removing list items in C# / XNA
Removing an item from the iterating list decrement the count therefore: for(int i=rocketPosition.Count; i > 0 ; i--) { rocketPosition[i] = new Vector2(rocketPosition[i].X, rocketPosition[i].Y - rocketSpeed); Vector2 smokePosition = rocketPosition[i]; smokePosition.X += Rocket.Width / 2 + smokeTexture.Width / 2 + randomizer.Next(10) - 5; smokePosition.Y += Rocket.Height + randomizer.Next(10) - 5; smokeList.Add(new Particle(smokePosition, gameTime.TotalGameTime.Milliseconds)); if (rocketPosition[i].Y < 0 - Rocket.Height) { rocketPosition.RemoveAt(i); } } for(int i = smokeList.Count; i > 0 ; i--) { if (smokeList[i].Time < gameTime.TotalGameTime.Milliseconds - smokeDuration) { smokeList.RemoveAt(i); } }

Categories : C#

Removing last child in list
Seems like your CMS using Superfish's plug-in hack like this.. $('.SideCategoryListFlyout').on('mouseenter.sfremove',function(){ $('>ul > li', this).last().remove(); $(this).off('mouseenter.sfremove'); }); Demo : http://jsfiddle.net/2hFXx/2

Categories : Jquery



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.